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

GEEKY BANKERS CAIIB (IT) Keys in DBMS Complete

The document discusses different types of keys in a database management system including super keys, candidate keys, primary keys, unique keys, foreign keys, composite keys, and their relationships. It provides examples and definitions for each key type and explains how they uniquely identify records in database tables and help define relationships between tables. Constraints like domain constraints and referential integrity constraints are also summarized.

Uploaded by

rutesh2021
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views

GEEKY BANKERS CAIIB (IT) Keys in DBMS Complete

The document discusses different types of keys in a database management system including super keys, candidate keys, primary keys, unique keys, foreign keys, composite keys, and their relationships. It provides examples and definitions for each key type and explains how they uniquely identify records in database tables and help define relationships between tables. Constraints like domain constraints and referential integrity constraints are also summarized.

Uploaded by

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

Join GEEKY BANKER on YouTube

Geeky Bankers
CAIIB (IT)
Keys in DBMS
Join GEEKY BANKER on YouTube

CAIIB(IT)

Keys in DBMS

What we will study?

What is Different type of Keys in DBMS?

Super Keys, Candidate Key, Primary Key?

Foreign key, unique key, Composite Key?

Super Key – A super key is a group of single or multiple attributes which uniquely
identifies rows in a table. A super key is a candidate key’s superset or in other word
candidate key is the subset of super key.

EMP_ID EMP_NAME EMP_PAN EMP_MAIL EMP_AGE


101 GANESH AWERP0543 [email protected] 32
102 NITU AWERP0544 [email protected] 26
103 MANI AWERP0545 [email protected] 33
104 MALKIT AWERP0546 [email protected] 27
105 NILESH AWERP0547 [email protected] 30
106 RATNA AWERP0548 [email protected] 28
107 ROSHNI AWERP0549 [email protected] 27
108 RITESH AWERP0550 [email protected] 26
109 RAMESH AWERP0551 [email protected] 31

Super Keys:-

{EMP_ID} {EMP_ID,EMP_NAME}
{EMP_PAN} {EMP_PAN,EMP_NAME}
{EMP_MAIL} {EMP_ID,EMP_PAN,EMP_AGE}
{EMP_ID,EMP_AGE} {EMP_MAIL,EMP_PAN,EMP_NAME}
Join GEEKY BANKER on YouTube

Candidate Key: - A candidate key is an attribute or set of attributes that can uniquely
identify a tuple. Except for the primary key, the remaining attributes are considered a
candidate key. In a table, we select the primary key from a candidate key.

 It is a minimal super key.


 It is a super key with no repeated data is called a candidate key.
 The minimal set of attributes that can uniquely identify a record.
 It must contain unique values.
 It cannot contain NULL values.
 A candidate key is a super key but vice versa is not true.

EMP_ID EMP_NAME EMP_PAN EMP_MAIL EMP_AGE


101 GANESH AWERP0543 [email protected] 32
102 NITU AWERP0544 [email protected] 26
103 MANI AWERP0545 [email protected] 33
104 MALKIT AWERP0546 [email protected] 27
105 NILESH AWERP0547 [email protected] 30
106 RATNA AWERP0548 [email protected] 28
107 ROSHNI AWERP0549 [email protected] 27
108 RITESH AWERP0550 [email protected] 26
109 RAMESH AWERP0551 [email protected] 31

Candidate keys are:- EMP_ID,EMP_PAN,EMP_MAIL

Primary Key: - Primary Key is an attribute or group of attribute in a table that can
uniquely identify every row in a table.

 It can identify only one tuple (a record) at a time.


 It has no duplicate values, it has unique values.
 It cannot be NULL.
Join GEEKY BANKER on YouTube

EMP_ID EMP_NAME EMP_PAN EMP_MAIL EMP_AGE


101 GANESH AWERP0543 [email protected] 32
102 NITU AWERP0544 [email protected] 26
103 MANI AWERP0545 [email protected] 33
104 MALKIT AWERP0546 [email protected] 27
105 NILESH AWERP0547 [email protected] 30
106 RATNA AWERP0548 [email protected] 28
107 ROSHNI AWERP0549 [email protected] 27
108 RITESH AWERP0550 [email protected] 26
109 RAMESH AWERP0551 [email protected] 31

Primary Key are- EMP_ID,EMP_PAN,EMP_MAIL.

Relationship among Keys


Join GEEKY BANKER on YouTube

Unique Key:- A unique key is a set of one or more than one fields/columns of a table
that uniquely identify a record in a database table.

Primary key will not accept NULL values whereas Unique key can accept NULL values. A
table can have only one primary key whereas there can be multiple unique key on a table.

Foreign Key:- A foreign key is an attribute in a table that acts as the primary key in
another table. Hence, the foreign key is useful in linking together two tables.

Here Dept_Id in Employ table is Foreign key.


Join GEEKY BANKER on YouTube

Alternate Key or Secondary Key :- Alternate Key or Secondary Key is the


key that has not been selected to be the primary key, but are candidate
keys. However, it is considered a candidate key for the primary key. A candidate
key not selected as a primary key is called alternate or secondary key.

Composite Key :- The composite key refers to a set of more than one
attributes that help us uniquely identify each tuple in a table. The attributes
present in a set may not be unique whenever we consider them separately.
Thus, when we take them all together, it will ensure uniqueness otherwise not.

Constraints in Database

There are several types of constraints available in DBMS and they are:
1. Domain constraints.
2. Entity Integrity constraints.
3. Referential Integrity constraints.

Domain constraints: - Domain Constraints are user-defined restrictions on


attribute that help the user to enter the value according to the data type specified
for that attribute. Domain constraints can be defined as the definition of a valid
set of values for an attribute. The data type of domain includes string, character,
integer, time, date, currency, etc.

Entity Integrity constraints: - Entity Integrity Constraint is used to ensure


that the primary key cannot be null. A primary key is used to identify individual
records in a table and if the primary key has a null value, then we can't identify
those records.
Join GEEKY BANKER on YouTube

Referential Integrity constraints: - A foreign key constraint (also referred to


as a referential constraint or a referential integrity constraint) is a logical rule
about values in one or more columns in one or more tables. Foreign key of one
relation should match the primary key of another relation.
Join GEEKY BANKER on YouTube

Thanks for Watching

Please visit my Telegram Channel to download all the PDFS.

Telegram Channel Link ->https://t.me/+bxiH9olUQ1tlODJl

For any query please drop Whatsapp Message on

9835634545

You might also like