0% found this document useful (0 votes)
7 views

Class 4

dbms unit-1
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Class 4

dbms unit-1
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Key:-

A key is an attribute (Colum) or set of attribute that uniquely identify any


row (tuple) from the database table.

It is also used to establish and identify relationship between tables.

Types of keys:

1. Super Key

A Super key is a combination of all possible attributes that can uniquely identify the
row(or tuple) in the given relation
2. Super key is a superset of candidate key.
3. A table can have much supper key.
4. A super key may have additional attribute that are not needed for unique identity and
have null value.

…etc

2. Candidate Key :-
A Candidate key is an attribute or set of an attribute which can uniquely identify a
tuple(row).
It is also called the minimal super Key because we select of candidate key form set of
super key such that select candidate key is the minimum attribute required to uniquely
identify a tuple.

1. It is the minimal super key


2. Candidate key is the subset of super key.
3. A table can have many candidates key.
4. Candidate key have not allow the null value.
3. Primary Key :-
A primary key is one pf the candidate key chosen by the database designer
to uniquely identify the tuple in the relation.

 The value of primary key can never br NULL.


 The value of primary key must always be unique (not duplicate).
 The value of primary key can never be changed (no updation is possible)
 The value of primary key must be assigned when inserting a record in table.
 A relation is allowed to have only one primary key.

4. Alternate Key: - Out of all Candidate keys, Only one gets selected as primary key,
remaining Keys are known as alternative Keys.

In the above Table, Emp _id is the best suitable for primary key so rest of candidate key
(Email_id , Addhar_no) are considered as candidate key
5. Foreign Key :-
A key used to link two tables together.
An attribute or set of attributes in one table that refer to the primary key in another
table.
Foreign key is ensure (or maintain) referential integrity of the data.

 Foreign Key references the primary key of the table


 Foreign key can take only those values which are present in the primary key of the
referenced relation.
 Foreign key may have a name other than that of a primary key.
 Foreign key can take the NULL value.
 There is no restriction on a foreign key to be unique.
 In fact, foreign key is not unique most of the time.
 Referenced relation may also be called as the master table or primary table.
 Referencing relation may also be called as the foreign table.

You might also like