Entity Relationship Model : Concept of Keys

Concept of Keys :

Key plays an important role in relational database, Key is an attribute or collection of attributes that uniquely identifies an entity among entity set. They are used to establish and identify relation between tables. They also ensure that each record within a table can be uniquely identified by combination of one or more fields within a table. For example, Employee_id of an Employee makes him/her identifiable among other employees. Keys also help uniquely identify relationships, and thus distinguish relationships from each other.

Types of keys : 

1. Super key : A super-key is a set of one or more attributes that collectively identifies an entity in an entity set. For example Roll No. of a student is unique in relation. The set of properties like roll no., name, address is a super key for the relation student.

2. Candidate key : A minimal super key is called a candidate key. An entity set may have more than one candidate key. Every table must have at least one candidate key or several candidate keys. It is a super key’s subset.

3. Primary Key : The key which is unique as well as not null is called as primary key. Primary key is a candidate key that is most appropriate to become main key of the table. It is a key that uniquely identify each record in a table.

4. Composite Primary key : When the data is not uniquely stored and retrieved by using a single primary key. We can combine  two or more columns to make composite primary key. So then we are able to access data uniquely.

5. Foreign Key : This key is also called as a referential integrity. This key always refer to the parent or master table that is ie, A table which contain a primary key. Generally foreign key is a primary key from one table, which has a relationship with another table. Foreign keys helps to establish the mapping between two or more entities.

6. Alternate key : The candidate key which are not selected for primary key are known as secondary keys or alternate keys.

Next Topic : -
                        RDBMS List

No comments:

Post a Comment