4. Keys and its
importance
Keys play an important role in the relational database.
It is used to uniquely identify any record or row of data
from the table. It is also used to establish and
identify relationships between tables.
For example: In Student table, ID is used as a key because
it is unique for each student. In PERSON table,
passport_number, license_number, SSN are keys since
they are unique for each person.
7. Super Key
Super Key is the superset of primary key. The super key
contains a set of attributes, including the primary key,
which can uniquely identify any data row in the table.
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.
8. Candidate
key
Candidate Key - The candidate keys in a table are defined
as the set of keys that is minimal and can uniquely
identify any data row in the table.
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.
9. Primary
Key
The primary key is selected from one of the candidate
keys and becomes the identifying key of a table. It can
uniquely identify any data row of the table.
In the EMPLOYEE table, ID can be primary key since it is
unique for each employee. In the EMPLOYEE table, we
can even select License_Number and Passport_Number
as primary key since they are also unique.
10. Foreign
key
A foreign key is an attribute value in a table that acts as
the primary key in another table. Hence, the foreign
key is useful in linking together two tables.
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.
Now in the EMPLOYEE table, Department_Id is the
foreign key, and both the tables are related.
12. Composite Key - If any single attribute of a table is not
capable of being the key i.e it cannot identify a row
uniquely, then we combine two or more attributes to
form a key. This is known as a composite key.
Secondary Key - Only one of the candidate keys is
selected as the primary key. The rest of them are
known as secondary keys.
14. Qui
z
1. . A in a table represents a relationship among a set
of values.
a) Column
b) Key
c) Row
d) Entry
Answer: C
15. 2. The term attribute refers to a of a
table.
a) Record
b) Column
c) Tuple
d) Key
Answer:
B