0% found this document useful (0 votes)
18 views16 pages

Dbms

The document discusses different types of keys in database management systems (DBMS). It defines candidate keys as fields that can uniquely identify rows, and the primary key as the chosen candidate key that uniquely identifies rows. It also discusses super keys (fields that identify rows but allow duplicates), alternate keys (other candidate keys besides the primary key), foreign keys (fields used as primary keys in another table), composite keys (multiple fields forming a unique identifier), and unique keys (fields requiring unique values but allowing one null value).

Uploaded by

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

Dbms

The document discusses different types of keys in database management systems (DBMS). It defines candidate keys as fields that can uniquely identify rows, and the primary key as the chosen candidate key that uniquely identifies rows. It also discusses super keys (fields that identify rows but allow duplicates), alternate keys (other candidate keys besides the primary key), foreign keys (fields used as primary keys in another table), composite keys (multiple fields forming a unique identifier), and unique keys (fields requiring unique values but allowing one null value).

Uploaded by

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

Different types of keys in

Dbms
By: Kachhawah Nikhil Surendra
01 Candidate Key
1. Candidate key
The candidate keys in a table are defined as the set of keys that is minimal and can
uniquely identify any data row in the table.
• It must be unique
• It can not be null

For example:

Here candidate key can be:


• Student_Number
• Student_Phone
03 Primary Key
2. Primary key
The primary key is selected from one of the candidate keys and becomes the identifying
key of a table. It can uniquely identify any data row of the table.

• All the values of a primary key have to be different


• It can not be null
• A table can have only one primary key; and in the table, this primary key can consist
of single or multiple columns (fields).

For example:

Suppose here programmer choose Student_Number as the primary key


03 Super Key
3. Super key
• A super key refers to the set of all those keys that help us uniquely identify all the rows present
in a table. It means that all of these columns present in a table that can identify the columns of
that table uniquely act as the super keys.
• Super Key is the superset of primary key.

For example:
All these can be super key for above table:

• Student_Number
• Student_Phone
• Student_Number, Student_Name
• Student_Number, Student_Phone
• Student_Number, Subject_Number
• Student_Phone, Student_Name
• Student_Phone, Subject_Number
• Student_Number, Student_Name, Student_Phone
• Student_Number, Student_Phone, Subject_Number
• Student_Number, Student_Name, Subject_Number
• Student_Phone, Student_Name, Subject_Number
04 Alternate Key
4. Alternate key
• Only one of the candidate keys is selected as the primary key. The rest of them
are known as alternate keys.
• It is also known as secondary key.

For example:

Suppose here programmer choose Student_Number as the primary key.


Then Alternate key can be one from the left out candidate key

As Student_Number is primary key the Alternate key can be:


• Student_Number
05 Foreign Key
4. Foreign key
• A foreign key is an attribute value in a table that acts as the primary key in another
table. Hence, the foreign key is useful in linking together two tables.
• A foreign key helps us to maintain data as well as referential integrity.

For example:

PK FK

Here DepNo in first table is used as foreign key in another to establish relation
06 Composite Key
4. Composite key
If any single attribute of a table is not capable of being the key i.e it cannot identify a
row uniquely, then we combine two or more attributes to form a key. This is known
as a composite key.

For example:
07 Unique Key
4. Unique key
• A unique key refers to a column/a set of columns that identify every record
uniquely in a table. All the values in this key would have to be unique.
• Remember that a unique key is different from a primary key. It is because it is
only capable of having one null value.

For example:

Here candidate key can be:


• Student_Number
• Student_Phone

You might also like