Site icon i2tutorials

DBMS – Keys

Keys In DBMS

 

What are keys?

A set of attributes of a relation, where the values of that set of attributes allow us to uniquely identify a single tuple.

 

There are 5 different kinds of Keys: 

Ex :  S-No, S-Name

Ex :  S-No

Candidate Key is a Minimal Super Key

 Ex :   S-No

Ex :   S-Name

Let’s say some of the attributes are common between these two relations. Let K1 be the Primary Key in R1. Let K2 be the Primary Key in R2.

If K2 is also present in R1, it is said to be the ‘Foreign Key’ in R1 because it is the primary key in R2.

 

Let’s take an example:

R1: Student

S-NoS-NameD-No
241Alex14
267Max14
283Maggie15
292Ben15
304Trex16

 

R2 : Department

D-NoD-name
14CSE
15IT
15IT
16EEE
17AI

 

Here,  D-No in R1 is said to be ‘Foreign Key’ because D-No in R2 is the Primary Key.

 

Reference :

Keys In DBMS.

 

 

Exit mobile version