Keys in DBMS
A superkey is a set of one or more
attributes that allows us to uniquely identify an entity in entity set. For
example, the customer_id attribute of entity set customer distinguishes
one customer from another. Hence, customer_id is a superkey. The customer_name
attribute of entity customer cannot be superkey because, two customers
can have same name. Another example, the combination of customer_id and customer_name
is also a superkey for entity customer.
Let R be a relationship having entity sets E1,
E2, …, En. Let Ei be the primary-key to denote the set of
attributes for entity set Ei. The composition of primary key depends on
the set of attributes associated with relationship set R.
If the relationship set R has no attributes associated
with it, then the set of attributes describes an individual relationship in set
R.
primary-key(E1) ∪ primary-key(E2) ∪ · · · ∪ primary-key(En)
If the relationship set R has the attributes a1,
a2, …, am associated with it, then the set of attributes
describes an individual relationship in set R.
primary-key(E1) ∪ primary-key(E2) ∪ · · · ∪ primary-key(En) ∪ {a1,
a2, …, am}
In both the above examples, the set of attributes
forms a superkey for the relationship set.
Comments
Post a Comment