1. we have in
• A Key is an attribute or a set of attributes in a relation that identifies a tuple
(record) in a relation.
• The keys are defined in a table to access or sequence
and smoothly.
the stored data quickly $
• They are also used to create relationship between differenttables.
2.
3. ary
• Which is Unique Can’t be have FULL Value
• Is the column you choose to maintain uniqueness in a table at
row level.
• Here in Emplcyee table we can choose either fi wpfoyr rID or SSU column for a PK.
• E mployeeID is preferable choice because SSN is a secure (PII) value.
• Primary key is the minimal super keys. In the ER diagram primary key is
represented by underlining the primary keyattribute.
,EmployeelD
EmployeeName
SSN
• Ideally a primary key is composed of only a single attribute. DeptlD
• But it is possible to have a primary key composed of more than one attribute
DOB
4. To deLine a Lield as primary hey,
following conditions had to be met :
• No two rows can have the same primary hey value.
• Every row must have a primary hey value.
• The primary hey field cannot be null.
• Value in a primary hey column can never be modified or updated, if any
foreign hey refers to that primary hey
5. • Are individual columns in a table that qualifies for
uniqueness of each row/ tuple.
• Here in fi»iplo¿ree table Sm ploye e ID & SSN are
for a Prim ary Key and thus are Candidate keys.
eligible
EmgloyeelD
EmployeeName
• Candidate Keys are super lxeys for which no proper subset SSN
is a super hey. In othe r words candidff te k PJS ff J DeptlD
minim al super keys.
DOB
6. rnate
„„,j,| • Candidate column other the Primary column, lilxe if | ir, - ; '- - -.
Em ploye elD is set for a PK then SSN would be the J mpl Oyee 1D
Alternate hey.
EmployeeName
SSN
DeptlD
DOB
7. r
g„„,j,| • If you add any other Column /Attribute to a Primary Key |•’ ----- "
then it become a Super Key, lilxe Sm ployee ID '
EmgloyeelD
+Em ployeeNam e is a Super Key.
• Super key stands for superset of a hey.
EmployeeName
• A Super Key is a set of one or m ore attribute s that are SSN
taAe n colle ctive ly and can identify allother attr DeptlD
uniquely.
DOB
8. • If a table do have a single column that qualifies for a Candidate
key, then you have to select 2 or more columns to make a row
unique.
• Like if there is no E mployeeID or SSN columns, then you can
EmployeelD
EmployeeName
make Em ploye e Nam e + Date O fBirth (DOB) as Composite S
' N
Prim ary Key. But stillAae an & a mrrov dlano: A AQi>te revs. Deptio
DOB
9. ign
g „„,j| • Here in below tables De ptID of De partment table is Primary Key where as
De ptID of fi»tplo,;yee is an Foreign Aey.
• It means it has referred to another table. This concept is also know as
AeJerential Integrity.
EmployeelD
Employee Name
SSN
DeptlD
DOB
DetID
DeptName
10. „„,j,| • Unique Aey is same as primary with the diZerence
being the existence of null.
• Unique hey field allows one value as NULL value.
EmployeelD
EmployeeName
SSN
EmaillD
DOB