Rdbms
Rdbms
emphyee.3
A Stucent, Ca, Bcolk
cnty
tyeá f entttes
Gclechan < Sla
Colkge ma
Ex:: Al shudenta in a
A et Samf
seta.
1. Super Key
The set of one or more attributes (columns) that can uniquely identify a
tuple (record) is known as Super Key. t may include extra attributes
that aren't essential for uniqueness but stilluniquely identify the row. For
Example, STUD_NO, (STUDNO, STUD_NAME), etc.
Asuper key is a group of single or multiple keys that uniquely
identifies rows in atable. It supports NULL values in
rows.
A super key can contain extra attributes that aren't
necessary for
uniqueness. For example, if the "STUDNO" column can uniquely
identify a student, adding "SNAME" to it will still form a valid
super key, though it's unnecessary.
Example: Consider the STUDENT table
Super Key
Candidate Key
Primary Key
Relatio
n between Primary Key, Candidate Key, and Super Key
2. Candidate Key
The minimal set of attributes
that canuniquely identify atuple is known
as a candidate key. For Example, STUD NO in STUDENT
relation.
A candidate key is a minimal super key, meaning it can
uniqueiy
identify a record but contains no extra attributes.
" lt is a super key with no repeated data is called a
candidate key.
The minimalset of attributes that can uniquely identify
a record.
" Acandidate key must contain unique values,
ensuring that no two
rows have the same value in the candidate key's columns.
Table STUDENTCOURSE
1 O01 CO01
2 COOS
It must have unique values and cannot contain any duplicate values.
A primary key cannot be NULL, as it needs to provide avalid,
unique identifier for every record.
Aprimary key does not have to consist of a single column. In some
cases, a composite primary key (made of multiple columns) can be
used to uniquely identify records in a table.
Databases typically store rows ordered in memory according to
primary key for fast access of records using primary key.
Example:
STUDENT table -> StudentSTUD NO, SNAME, ADDRESS, PHOWE) »
STUDNOis a primary key
Table STUDENT
1
Shyam Delhi 123456789
4. Altemate Key
An alternate key is any candidate key in atable that is not chosen as the
primary key. In other words, all the keys that are not selected as the
primary key are considered alternate keys.
An alternate key is also referred to as a secondary key because it
Can uniquely identify records in a table, just like the primary key.
An alternate key can consist of one or more columns (fields) that
can uniquely identify a record, but it is not the primary key
Eq:- SNAME, and ADDRESS is Alternate keys
Primary Key
Alternate Key
For example, DNO is a primary key in the DEPT table and a non
key in EMP
1 O0S COO1
OS6 COOs
It has been repeated for the first and third tuples. However, the
STUD_NO in STUDENT relation is a primary key and it needs to be
always unique, and it cannot be null.
Example: In the sTUDENT COURSE table, (STUD NO, COURSE NO} can form
a composite key to uniquely identify each record.
Candidate Key Foreign Key
Table 1 Table 2
Dld Designation
EmplDEmp Name EmpLicence EmpPassport DId
Primary Key
Alternate Key Primary Key Candidate Key Alternate Key
Superkey
Unique Key