DBMS Lecture 4
DBMS Lecture 4
Chapter 4
(Week 8,9 &10)
Keys
A. Entity Sets
1. Superkey – A superkey is a set of one or
more attributes that, taken collectively, allow
identifying uniquely an entity in the entity set.
A superkey may contain extraneous
attributes.
customer – {customer-id}, {customer-name,
customer-id}, {all attribute}
customer-name is not a superkey
Keys
2. Candidate Key – The superkey for which no
proper subset is a superkey is a candidate key. So
the minimul superkeys are called is candidate
keys.
It is possible that several distinct sets of attributes
could serve as a candidate key.
{customer-name, customer-street},{customer-id}
{customer-id, customer-name} is not a candidate
key because customer-id itself is a super
key/candidate key.
Keys
In Branch-schema – {branch-name},
{branch-name, branch-city}, {all attribute}
are all superkeys. {branch-name, branch-
city} is not a candidate key, because
{branch-name} is a subset of {branch-
name, branch-city} and {branch-name}
itself is a superkey.
However, {branch-name} is a candidate
key and also a primary key for our
purpose. {branch-city} is not a superkey,
since two branches in the same city may
have different names
Keys
B. Relationship Sets
Superkey: Let R be a relationship set involving entity
sets E1, E2, ….., En. Let Primary Key (Ei ) denote the
set of attributes that forms the primary key for entity set
Ei. Assume for now that the attribute names of all the
primary keys are unique, and each entity set participates
only ones in the relationship. The composition of the
primary key for a relationship set depends on the set of
attributes associated with the relationship set R.
Keys
i) If the relationship set R has no attributes
associated with it (descriptive attribute/s),
then the set of attributes
Primary Key (E1 ) U Primary Key (E2 )
U…..U Primary Key (En)
describes an individual relationship in set R.
Keys
2. Partial generalization or
specialization: Some higher-level
entities may not belong to any lower-
level entity set.
Example: Employee and Team
Abstraction