DBMS
DBMS
CSCP 254
LECTURE 7. KEYS
2. Candidate key
A candidate key is an attribute or set of an
attribute which can uniquely identify a tuple.
The remaining attributes except for primary key
are considered as a candidate key. The
candidate keys are as strong as the primary key.
For example: In the EMPLOYEE table, id is best suited for the
primary key. Rest of the attributes like SSN, Passport Number, and
License Number, etc. are considered as a candidate key.
TYPES OF KEYS
3. Super Key
Super key is a set of an attribute which can uniquely identify a
tuple. Super key is a superset of a candidate key.
For example: In the above EMPLOYEE table,
for(EMPLOEE_ID, EMPLOYEE_NAME) the name of two
employees can be the same, but their EMPLYEE_ID can't be the
same. Hence, this combination can also be a key.
The super key would be EMPLOYEE-ID, (EMPLOYEE_ID,
EMPLOYEE-NAME), etc.
TYPES OF KEYS
4. Foreign key
Foreign keys are the column of the table which is used to point to
the primary key of another table.
In a company, every employee works in a specific department,
and employee and department are two different entities. So we
can't store the information of the department in the employee
table. That's why we link these two tables through the primary key
of one table.
We add the primary key of the DEPARTMENT table,
Department_Id as a new attribute in the EMPLOYEE table.
o Now in the EMPLOYEE table, Department_Id is the foreign
key, and both the tables are related.
GENERALIZATION
Generalization is like a bottom-up approach in which two or more
entities of lower level combine to form a higher level entity if they have
some attributes in common.
In generalization, an entity of a higher level can also combine with the
entities of the lower level to form a further higher level entity.
Generalization is more like subclass and superclass system, but the only
difference is the approach. Generalization uses the bottom-up approach.
In generalization, entities are combined to form a more generalized
entity, i.e., subclasses are combined to make a superclass.
For example, Faculty and Student entities can be generalized and
create a higher level entity Person.
SPECIALIZATION