Types of keys in E-R modeling
- Super key: Allows us to identify uniquely an entity in the entity set. Example: Roll_No attribute of student distinguishes student entity from another.
- Candidate key: A superkey for which no subset is a superkey. Example: Roll_No and {Student_Name, Student_street} are candidate keys
- Primary key: It is a candidate key that is chosen by the database designer as the principle means of identifying entities within an entity set. Example: Address field should not be a primary key whereas Social Security Number can be a primary key.
- Foreign key: An attribute or set of attributes, within one relation that matches the candidate key of some relation. Example: Branch_no in Branch table is primary key. Branch_no in Staff table is foreign key that connects to Branch table.