You are on page 1of 15

In this example. we could use SCN as a key because it uniquely identifies a pupil record. No other pupil can have the same SCN (Scottish Candidate Number).Keys A key is a field or set of fields whose values uniquely identify a record. No other fields can uniquely identify each pupil record .

both Employee Number and Email are candidate keys.Candidate Key Any field or set of fields which can be considered as a key is known as a candidate key In this example. because both can uniquely identify the employee record in the table .

A primary key consisting of only one field is known as an atomic key . Given this. it would be better to use Employee Number as a primary key as this is less likely to change. it's possible that the company may change the structure of staff email addresses.Primary Key The primary key is the candidate key which is chosen to be used In the example above.

Compound Key It is possible in some tables that no one column can act as a primary key. and that a combination of columns are required to create the key. This is known as a compound key. Order ID cannot be a primary key as it does not uniquely identify a record Product ID cannot be a primary key as it does not uniquely identify a record .

A compound key of Order ID and Product ID could be used because this is unique for each record. and that a combination of columns are required to create the key.Compound Key It is possible in some tables that no one column can act as a primary key. . This is known as a compound key.

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.

a surrogate key must be created in order to uniquely identify them. In this example. KTV have been interviewing passers-by for the evening news bulletin.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. As these people are not related to KTV in anyway. The production team take a note of the interviewee's name and the duration of the interview. .

a surrogate key must be created in order to uniquely identify them. KTV have been interviewing passers-by for the evening news bulletin. A new column is created to be the primary key. The production team take a note of the interviewee's name and the duration of the interview. Surrogate keys are often a combination of letters and numbers. As these people are not related to KTV in anyway.Surrogate Key A surrogate key is a special key which has no meaning or purpose other than to uniquely identify each record. . In this example.

teachers and departments in a school.Foreign Key A foreign key is a column which is added to one table to create a relationship with another table. In this example we have two tables. . But there is no way to see which teacher works in which department.

. By adding the foreign key Department Code to the Teacher table. we can create a relationship between the two tables.Foreign Key A foreign key is a column which is added to one table to create a relationship with another table.

We represent foreign keys with an asterisk. .Key Notation We represent primary keys by underlining them.

name.Key Notation We represent primary keys by underlining them. We represent foreign keys with an asterisk. dob. surname. photo) pupil (candidate_num. expiry_date. forename. card_num*) . young scot card (card_num.

forename. subject. duration) result (candidate_num*. dob. surname. level. postcode) exam (exam_id. pupil (candidate_num. exam_id*. grade) .Key Notation We represent primary keys by underlining them. We represent foreign keys with an asterisk.

telephone) screening (cinema*. certificate. rating) cinema (cinema_id. We represent foreign keys with an asterisk. date. movie*. city. time) .Key Notation We represent primary keys by underlining them. movie (movie_id. name.