0% found this document useful (0 votes)
13 views12 pages

Database Keys

The document provides an overview of database keys, which are essential for establishing relationships between tables in a relational database model. It explains different types of keys including super keys, candidate keys, primary keys, and foreign keys, with examples for clarity. The importance of these keys in uniquely identifying records and linking tables is emphasized.

Uploaded by

shazilgta6
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)
13 views12 pages

Database Keys

The document provides an overview of database keys, which are essential for establishing relationships between tables in a relational database model. It explains different types of keys including super keys, candidate keys, primary keys, and foreign keys, with examples for clarity. The importance of these keys in uniquely identifying records and linking tables is emphasized.

Uploaded by

shazilgta6
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/ 12

Introduction to

Database Keys

LECTURE 5
What are keys in database?
Keys are very important part of Relational database
model.

They are used to establish and identify relationships


between tables
Super key
A superkey is a set of one or more columns that can
uniquely identify each row in a table.
Super key

StudentID Email Phone Name


1 [email protected] 1234567890 Alice
2 [email protected] 9876543210 Bob


uper Key Examples:
S

◦StudentID (unique for every


student)
◦Email (unique for every student)
◦{StudentID, Email} (still unique,
but extra information)
Candidate key
Candidate key is a minimal subset of a super key.

A candidate key is a superkey that does not contain any


unnecessary columns.
CANDIDATE KEY

Candidate Key: (StudentID or Email alone).


PRIMARY KEY
Primary key is a candidate key
that is most appropriate to
become the main key for any
table.
nOOot Nnull
nnn
PRIMARY KEY

Student id as primary key


FOREIGN KEY

FOREIGN KEY IS USED TO CREATE RELATIONSHIP BETWEEN


THE TWO TABLES WITH EACH OTHER.
FOREIGN KEY
Lets say we have student table
Stu_Id Stu_Name Stu_Age
101 Chaitanya 22
102 Arya 26
103 Bran 25
104 Jon 21

And we want to link it with course table, then we will refer


Stu_id
key to course table and that Stu_id in the course tbl will
be known
Course_Id Stu_Id

as a
C01Foreign key 101
C02 102
C03 101
C05 102
COMPOSTIE KEY
THANKS

You might also like