100% found this document useful (1 vote)
1K views4 pages

Keys in DBMS

The document defines and provides examples of different types of keys in database management systems (DBMS), including super keys, candidate keys, primary keys, alternate keys, and foreign keys. A super key can uniquely identify records but can have multiple attributes, while a candidate key is a minimal super key. The primary key is the candidate key selected by the database designer. Unused candidate keys are alternate keys. A foreign key links records between tables by matching to the primary key of another table.

Uploaded by

Mayank Goswami
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views4 pages

Keys in DBMS

The document defines and provides examples of different types of keys in database management systems (DBMS), including super keys, candidate keys, primary keys, alternate keys, and foreign keys. A super key can uniquely identify records but can have multiple attributes, while a candidate key is a minimal super key. The primary key is the candidate key selected by the database designer. Unused candidate keys are alternate keys. A foreign key links records between tables by matching to the primary key of another table.

Uploaded by

Mayank Goswami
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Key in DBMS

Keys in DBMS-

A key is a set of attributes that can identify each tuple uniquely in the given relation.

Before proceeding further, Kindly note-


 The terms ‘relation’ and ‘table’ are used interchangeably.
 The terms ‘tuple’ and ‘record’ are used interchangeably.
So, don’t get confused!

1. Super Key-

 A super key is a set of attributes that can identify each tuple uniquely in the given relation.
 A super key is not restricted to have any specific number of attributes.
 Thus, a super key may consist of any number of attributes.

Example-

Consider the following Student schema-


Student ( roll , name , age , address , class , section, mob )

Given below are the examples of super keys since each set can uniquely identify each
student in the Student table-
 ( roll , name , age , address , class , section )
 ( class , section , roll )
 (class , section , roll , mob)
 ( name , address )

NOTE-

All the attributes in a super key are definitely sufficient to identify each tuple uniquely in the
given relation but all of them may not be necessary.

Ashish Chaturvedi, Dept. of CSE, LNCTE Page 1


Key in DBMS

2. Candidate Key-

A minimal super key is called as a candidate key.


or
A set of minimal attribute(s) that can identify each tuple uniquely in the given relation is
called as a candidate key.

Example-

Consider the following Student schema-


Student ( roll , name , age , address , class , section, Mob )

Given below are the examples of candidate keys since each set consists of minimal
attributes required to identify each student uniquely in the Student table-
 (roll )
 (Mob)
 ( name , address )

NOTES-

 All the attributes in a candidate key are sufficient as well as necessary to identify each
tuple uniquely.
 Removing any attribute from the candidate key fails in identifying each tuple uniquely.
 The value of candidate key must always be unique.
 The value of candidate key can never be NULL.
 It is possible to have multiple candidate keys in a relation.
 Those attributes which appears in some candidate key are called as prime attributes.

Ashish Chaturvedi, Dept. of CSE, LNCTE Page 2


Key in DBMS

3. Primary Key-

A primary key is a candidate key that the database designer selects while designing the
database.
OR
Candidate key that the database designer implements is called as a primary key.

NOTES-

 The value of primary key can never be NULL.


 The value of primary key must always be unique.
 The values of primary key can never be changed i.e. no updation is possible.
 The value of primary key must be assigned when inserting a record.
 A relation is allowed to have only one primary key.

Remember-

Ashish Chaturvedi, Dept. of CSE, LNCTE Page 3


Key in DBMS

4. Alternate Key-

Candidate keys that are left unimplemented or unused after implementing the primary key
are called as alternate keys.
OR
Unimplemented candidate keys are called as alternate keys.

5. Foreign Key-

o another table.
o In a company, every employee works in a specific department, and employee and
department are two different entities. So we can't store the information of the department
in the employee table. That's why we link these two tables through the primary key of
one table.
o We add the primary key of the DEPARTMENT table, Department_Id as a new attribute
in the EMPLOYEE table.
o Now in the EMPLOYEE table, Department_Id is the foreign key, and both the tables are
related.
o Foreign keys are the column of the table which is used to point to the primary key of

Ashish Chaturvedi, Dept. of CSE, LNCTE Page 4

You might also like