Documente Academic
Documente Profesional
Documente Cultură
In this example, both Employee Number and Email are candidate keys,
because both can uniquely identify the employee record in the table
Primary Key
The primary key is the candidate key which is chosen to be used
In the example above, it's possible that the company may change the structure
of staff email addresses. Given this, it would be better to use Employee
Number as a primary key as this is less likely to change.
In this example, KTV have been interviewing passers-by for the evening news
bulletin. The production team take a note of the interviewee's name and the
duration of the interview.
As these people are not related to KTV in anyway, a surrogate key must be
created in order to uniquely identify them.
Surrogate Key
A surrogate key is a special key which has no meaning or purpose other than to
uniquely identify each record. Surrogate keys are often a combination of letters
and numbers. A new column is created to be the primary key.
In this example, KTV have been interviewing passers-by for the evening news
bulletin. The production team take a note of the interviewee's name and the
duration of the interview.
As these people are not related to KTV in anyway, a surrogate key must be
created in order to uniquely identify them.
Foreign Key
A foreign key is a column which is added to one table to create a relationship
with another table.
By adding the foreign key Department Code to the Teacher table, we can
create a relationship between the two tables.
Key Notation
We represent primary keys by underlining them.