Primary Key
One or more columns which uniquely identiifes each row in the table.If there are more than 1 columns wich makes the row unique then its called as Composite Primary Key.
Unique Key
Same like primary key except that it allows 1 null value in the key columns
Candidate Key
A candidate key is one that can identify each row of a table uniquely. Generally a candidate key becomes the primary key of the table
Alternate Key
If the table has more than one candidate key, one of them will become the primary key, and the rest are called alternate keys.
Foreign Key
Primary key defined on 1 table is called as foreign key in the table which is referring the primary table.
To elaborate more , there is table employee which has employee ID as primary key and if we see Employee Salary table which has salary detail of employee,employee ID in salary table is called as Foreign key.
By this we enforce Employee has to be first present in Employee table and then only he can exist in Employee Salary table.
1 comment:
Post a Comment