Primary key - Primary key means main key
def:- A primary key is one which uniquely identifies a row
of a table. This key does not allow null values and also
does not allow duplicate values. For ex,
empno empname salary
1 firoz 35000
2 basha 34000
3 chintoo 40000
it will not the values as follows:
1 firoz 35000
1 basha 34000
chintoo 35000
foreign key - a foreign key is one which will refer to a
primary key of another table
for ex,
emp_table dept_table
empno empname salary deptno deptno deptname
In the above relation, deptno is there in emp_table which
is a primary key of dept_table. That means, deptno is
refering the dept_table.
Super Key:- superkey is a set of columns within a
table whose values can be used to uniquely identify a row.
A candidate key is a minimal set of columns necessary to identify a row, this is also
called a minimal superkey. For example, given an employee table,
consisting of the columns employeeID, name, job, and departmentID, we
could use the employeeID in combination with any or all other columns
of this table to uniquely identify a row in the table. Examples of
superkeys in this table would be {employeeID, Name}, {employeeID, Name,
job}, and {employeeID, Name, job, departmentID}.
def:- A primary key is one which uniquely identifies a row
of a table. This key does not allow null values and also
does not allow duplicate values. For ex,
empno empname salary
1 firoz 35000
2 basha 34000
3 chintoo 40000
it will not the values as follows:
1 firoz 35000
1 basha 34000
chintoo 35000
foreign key - a foreign key is one which will refer to a
primary key of another table
for ex,
emp_table dept_table
empno empname salary deptno deptno deptname
In the above relation, deptno is there in emp_table which
is a primary key of dept_table. That means, deptno is
refering the dept_table.
Super Key:- superkey is a set of columns within a
table whose values can be used to uniquely identify a row.
A candidate key is a minimal set of columns necessary to identify a row, this is also
called a minimal superkey. For example, given an employee table,
consisting of the columns employeeID, name, job, and departmentID, we
could use the employeeID in combination with any or all other columns
of this table to uniquely identify a row in the table. Examples of
superkeys in this table would be {employeeID, Name}, {employeeID, Name,
job}, and {employeeID, Name, job, departmentID}.