Tuesday, December 06, 2016

Keys in DBMS

KEY: - A key is a single attribute or combination of two or more attributes of an entity set that is used to identify one or more instances of the set. Eg. The attribute employee soc_sec_no. uniquely identifies while the employee skill would be unique i.e. Identify more than one instance.

PRIMARY KEY: - If there is a case two instances of an entity set could have the same value for all its attributes. Hence to distinguish such instances, we introduce the unique attribute and will identify an instance of the entity set. Such unique entity identifier is referred to as a PRIMARY KEY.

SUPER KEY: - If we add additional attributes to a primary key, the resulting combination would still uniquely identify an instance of the entity set. Such augmented keys are called SUPER KEYS. So here we called Primary Key is minimum SUPER KEY.

CANDIDATE KEY: - Candidate keys are defined as the set of fields from which primary key can be selected. It is an attribute or set of attribute that can act as a primary key for a table to uniquely identify each  record in that table.

COMPOSITE KEY:- Key that consists of two or more attributes that uniquely identify an entity is called Composite key. But any attribute that makes up the Composite key is not a simple key in its own.

ALTERNATE KEY: - In the case of candidate key we must decide which of the candidate key e must decide which of the candidate key will used as the primary key. The remaining candidate keys would be considered as ALTERNATE KEY.

SECONDARY KEY: - It is an attribute or combinations of attributes that classifies the entity set on a particular characteristic. It may not be a candidate key. Eg. The entity set EMPLOYEE having the attribute department, which identifies by its value all instances of EMPLOYEE who belongs to a given department. More than one employee may belong to a department, so the department attribute is not a candidate key for the entity set EMPLOYEE.

FOREIGN KEY :- A FOREIGN KEY is a field (or collection of fields) in one table, that refers to the PRIMARY KEY in another table. The table with the foreign key is called the child table, and the table with the primary key is called the referenced or parent table. 
Foreign keys are the columns of a table that points to the primary key of another table. They act as a cross-reference between tables.

No comments:

Post a Comment