2. Subject Name Code Credit Hours
Database System COMP 219 3
Keys
• It is used to uniquely identify entities within a
given entityset or a relationship set.
• Keys in Entity set:
• (i) Primary Key:
– It is a key used to uniquely identify an entity in the
entity set.
– E,g, eno,rno,dno etc…
3. Subject Name Code Credit Hours
Database System COMP 219 3
Keys
• Super Key:
• It is a set of one or more attributes that
allow us to uniquely identify an entity in the
entity set. Among them one must be a
primary key attribute.
• E.G.. Eid (primary key) and ename together
can be identify an entity in entity set.
4. Subject Name Code Credit Hours
Database System COMP 219 3
Keys
• Candidate key:
• They are minimal super keys for which no proper
subset is a superkey.
• E.g.. Ename and eaddr can be sufficient to identify an
employee in employee set.
• {eid} and {ename,eaddr} – Candidate keys
5. Subject Name Code Credit Hours
Database System COMP 219 3
FOREIGN -----------------------Keys
• An attribute which makes a reference to an
attribute of another entity type is called
foreign key
6. Subject Name Code Credit Hours
Database System COMP 219 3
Key
E.g…
eid Ename eaddr dno
dnamedno dloc
Employee – E1
Dept – E2
Foreign Ke
7. Subject Name Code Credit Hours
Database System COMP 219 3
Domain
• A range of values can be defined for an
attribute and is called as Domain of that attribute.
• E.g.. Age – attribute A
• Domain (A)= {1,2,….100}
8. Subject Name Code Credit Hours
Database System COMP 219 3
Keys in Relationship set:
• Case 1: If the relationship set R has no
attributes, then the set of attributes
Primarykey(E1) U Primarykey(E2) U
Primarykey (n)
Case2: If the relationship set R has attributes,
then the set of attributes,
9. Subject Name Code Credit Hours
Database System COMP 219 3
Keys in Relationship set
Primarykey(E1) U Primarykey(E2) U Primarykey
(n)U{a1,a2,…an}
describes an individual relationship in set R.
In both cases,
Primarykey(E1) U Primarykey(E2) U Primarykey (n)
forms a superkey for a relationship set.