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

Keys in Database Management System

Keys in databases are used to create relationships between tables and access data quickly. There are several types of keys including primary keys, foreign keys, super keys, candidate keys, alternate keys, composite keys, and unique keys. Primary keys must be unique and cannot contain null values, while foreign keys link data between tables by matching values to a primary key. Candidate keys are minimal super keys that uniquely identify each row.

Uploaded by

Joy Pal
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)
194 views

Keys in Database Management System

Keys in databases are used to create relationships between tables and access data quickly. There are several types of keys including primary keys, foreign keys, super keys, candidate keys, alternate keys, composite keys, and unique keys. Primary keys must be unique and cannot contain null values, while foreign keys link data between tables by matching values to a primary key. Candidate keys are minimal super keys that uniquely identify each row.

Uploaded by

Joy Pal
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/ 14

Presented By-

Joy Pal – 201002418


Jakir Hossain – 201002050
Shourav Podder – 202002048

1
KEYS in
DBMS
2
Index
SQL
Keys Explain Keys Command
1 3 5

2 4 6

Types of Conclusion
Example
Keys
3
Keys in DBMS

 Keys are used to create relationship between


different tables.

 The keys are defined in a table to access or


sequence the stored data quickly and smoothly.

 We can force identity of data and ensure


integrity of data is maintained.

4
Types
Candidate Key

Super Key Primary Key


of
Keys

Composite Key Foreign Key

Unique Key Alternate Key

5
Primary Key
 Primary Key is the minimal super Key.
 Ideally a primary key is composed of only a single attribute.
 Primary key field cannot be null.
 Its attribute values are never or very rarely changed.

SQL Command

CREATE TABLE EMPLOYEE(


Employee_ID varchar (10) PRIMARY KEY,
………….);
6
Foreign Key
 A foreign key is a combination of columns with values
based on the primary key values from another table.
 Also known as a referential integrity constraint.

SQL Command
CREATE TABLE EMPLOYEE(
…..,
FOREIGN KEY (Department_ID) REFERENCES EMPLOYEE(Department_ID)
………); 7
Super Key

 Super key is stand for superset of a key.


 A super key is a group of single or multiple keys
which identifies rows in a table.

8
Candidate Key

 Candidate keys are minimal super keys.


 Are individual columns in a table that qualifies for
uniqueness of each row/tuple.

9
Alternate Key

• An alternate is a secondary candidate key that is


capable of identifying a row uniquely.

10
Composite Key

Two or more attributes together form a composite


key that can uniquely identify a tuple in a table.

Composite Key

11
Unique Key

• Unique key is same as primary with the difference


being the existence of null.
• Unique key field allows on value as NULL value.

SQL Command

CREATE TABLE Employee (


…..,
EmailID varchar (20) NOT NULL,
Unique
UNIQUE (EmailID)
….); 12
Conclusion

Each table must have keys, because use of keys


make data highly reliable and provide several
types of content like unique data and null
values.

13
Thanks!

You might also like