0% found this document useful (0 votes)
101 views10 pages

Primary Key & Secondary Key and Primary Key Candidate Key & Composite Primary Key

Uploaded by

jindalaadhya22
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)
101 views10 pages

Primary Key & Secondary Key and Primary Key Candidate Key & Composite Primary Key

Uploaded by

jindalaadhya22
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/ 10

PRIMARY KEY &

SECONDARY KEY AND PRIMARY KEY


CANDIDATE KEY & COMPOSITE
PRIMARY KEY
AAHANA & AADHYA
primary key

A primary key is a unique


identifier for a record in a table. It
ensures that each record is unique
and can be uniquely identified by
this key.
Must contain unique values.
Cannot contain NULL values.
Each table can have only one
primary key.
Primary keys can be a single
column or a combination of
columns (composite primary
key).
SECONADRY key

Secondary key in DBMS is a


column or a set of columns in a
table that uniquely identifies each
row in a table that is not the
primary key.
Must contain unique values.
Can contain NULL values
(although it is less common).
A table can have multiple
secondary keys.
difference between primary and
foreign key
candidate key
The minimal set of attributes that can uniquely identify a tuple is known as a
candidate key. For Example, STUD_NO in STUDENT relation.
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 can contain NULL values.
Every table must have at least a single candidate key.
A table can have multiple candidate keys but only one primary key.
The value of the Candidate Key is unique and may be null for a tuple.
There can be more than one candidate key in a relationship.
candidate key example
composite key
a composite key is also a primary key, but the difference is that it is made by
the combination of more than one column to identify the particular row in the
table.
A composite key is made by the combination of two or more columns in a
table that can be used to uniquely identify each row in the table when the
columns are combined uniqueness of a row is guaranteed, but when it is
taken individually it does not guarantee uniqueness, or it can also be
understood as a primary key made by the combination of two or more
attributes to uniquely identify every row in a table.
It acts as a primary key if there is no primary key in a table
Two or more attributes are used together to make a composite key.
Different combinations of attributes may give different accuracy in terms
of identifying the rows uniquely.
composite key example
bibliography

https://www.geeksforgeeks.or
g/composite-key-in-sql/
https://www.geeksforgeeks.or
g/types-of-keys-in-relational-
model-candidate-super-
primary-alternate-and-
foreign/
https://databasetown.com/6-
types-of-keys-in-database/
Thank you!

You might also like