PPT: Concept of keys

Download, print and study this document offline
Please wait while the PDF view is loading
 Page 1


Concept of 
Keys in DBMS
Page 2


Concept of 
Keys in DBMS
Why we have Keys in DB?
Tuple Identification
A Key is an attribute or a set of attributes in a relation that identifies a tuple (record) in a 
relation.
Quick Data Access
The keys are defined in a table to access or sequence the stored data quickly and 
smoothly.
Table Relationships
They are also used to create relationship between different tables.
Page 3


Concept of 
Keys in DBMS
Why we have Keys in DB?
Tuple Identification
A Key is an attribute or a set of attributes in a relation that identifies a tuple (record) in a 
relation.
Quick Data Access
The keys are defined in a table to access or sequence the stored data quickly and 
smoothly.
Table Relationships
They are also used to create relationship between different tables.
Types of Keys in 
Database
1. Primary Key
2. Candidate Key
3. Alternate Key
4. Super Key
5. Foreign Key
6. Unique Key
An additional composite key is also there, 
which is a combination of multiple keys.
Page 4


Concept of 
Keys in DBMS
Why we have Keys in DB?
Tuple Identification
A Key is an attribute or a set of attributes in a relation that identifies a tuple (record) in a 
relation.
Quick Data Access
The keys are defined in a table to access or sequence the stored data quickly and 
smoothly.
Table Relationships
They are also used to create relationship between different tables.
Types of Keys in 
Database
1. Primary Key
2. Candidate Key
3. Alternate Key
4. Super Key
5. Foreign Key
6. Unique Key
An additional composite key is also there, 
which is a combination of multiple keys.
Primary Key
Unique & Non-NULL
Primary key is Unique & Can't 
have NULL Value
Row-Level Uniqueness
Used to maintain uniqueness in a 
table at row level.
Example
In the Employee table, we can 
choose the EmployeeID column 
for a PK.
Minimal Super Key
A primary key is the minimal 
super key. In the ER diagram, the 
primary key is represented by 
underlining the primary key 
attribute.
Ideally a primary key is composed 
of only a single attribute.
But it is possible to have a 
primary key composed of more 
than one attribute.
Page 5


Concept of 
Keys in DBMS
Why we have Keys in DB?
Tuple Identification
A Key is an attribute or a set of attributes in a relation that identifies a tuple (record) in a 
relation.
Quick Data Access
The keys are defined in a table to access or sequence the stored data quickly and 
smoothly.
Table Relationships
They are also used to create relationship between different tables.
Types of Keys in 
Database
1. Primary Key
2. Candidate Key
3. Alternate Key
4. Super Key
5. Foreign Key
6. Unique Key
An additional composite key is also there, 
which is a combination of multiple keys.
Primary Key
Unique & Non-NULL
Primary key is Unique & Can't 
have NULL Value
Row-Level Uniqueness
Used to maintain uniqueness in a 
table at row level.
Example
In the Employee table, we can 
choose the EmployeeID column 
for a PK.
Minimal Super Key
A primary key is the minimal 
super key. In the ER diagram, the 
primary key is represented by 
underlining the primary key 
attribute.
Ideally a primary key is composed 
of only a single attribute.
But it is possible to have a 
primary key composed of more 
than one attribute.
To define a field as a primary key, the following 
conditions had to be met :
Uniqueness
No two rows can have the same primary key value.
Mandatory
Every row must have a primary key value.
Non-NULL
The primary key field cannot be null.
Immutable
Value in a primary key column can never be modified or updated, if any foreign key refers to that primary key
Read More

FAQs on PPT: Concept of keys

1. What are the different types of keys in database management systems?
Ans. In database management systems, keys are essential for uniquely identifying records and establishing relationships between tables. The main types of keys include: 1. <b>Primary Key</b>: A unique identifier for each record in a table, ensuring no two rows have the same value. 2. <b>Foreign Key</b>: A field in one table that links to the primary key in another table, establishing a relationship between the two. 3. <b>Composite Key</b>: A combination of two or more fields in a table that uniquely identifies a record. 4. <b>Candidate Key</b>: Any column or set of columns that could serve as a primary key, but one is chosen as the primary key. 5. <b>Surrogate Key</b>: An artificially created key, often a number, that serves as a unique identifier for records without intrinsic meaning.
2. Why are keys important in relational databases?
Ans. Keys are crucial in relational databases as they ensure data integrity and establish relationships between tables. They help maintain the uniqueness of records, prevent data duplication, and facilitate efficient data retrieval through joins. By using keys, databases can enforce constraints, such as ensuring that a foreign key must match a primary key in another table, which helps maintain the accuracy and consistency of the data.
3. What is the difference between a primary key and a foreign key?
Ans. A primary key is a unique identifier for a record within its own table, ensuring that no two records can share the same primary key value. In contrast, a foreign key is used to link two tables together; it is a field in one table that references the primary key of another table. The primary key enforces entity integrity, while the foreign key enforces referential integrity between the related tables.
4. Can a table have multiple primary keys?
Ans. No, a table cannot have multiple primary keys. However, it can have multiple candidate keys, one of which is selected as the primary key. The primary key must uniquely identify each record in the table, and having more than one primary key would violate this principle. Instead, a table can utilize a composite key, which combines multiple fields to serve as a single primary key.
5. How do surrogate keys differ from natural keys?
Ans. Surrogate keys are artificial keys created to uniquely identify records in a database, typically using sequential numbers or unique identifiers that have no business meaning. Natural keys, on the other hand, are derived from the actual data and have a meaningful relationship to the data itself, such as Social Security numbers or email addresses. While natural keys can be useful, they may change over time, whereas surrogate keys remain stable and do not change, simplifying data management.
Explore Courses for Computer Science Engineering (CSE) exam
Related Searches
video lectures, Previous Year Questions with Solutions, past year papers, pdf , Exam, Viva Questions, PPT: Concept of keys, Semester Notes, Summary, PPT: Concept of keys, Extra Questions, Free, study material, Objective type Questions, Important questions, practice quizzes, shortcuts and tricks, ppt, mock tests for examination, MCQs, Sample Paper, PPT: Concept of keys;