teach-ict.com logo

THE education site for computer science and ICT

2. Primary Key

A primary key is a field (or combination of fields) in a table which is unique and enables you to identify every record in that table.

Imagine what would happen if Mrs Smith telephoned the school to ask the secretary to pass on a message to her daughter.

If there were nothing to uniquely identify the students' records, the secretary would have to search for all of the 'Smiths' in school and then say, 'sorry to keep you waiting Mrs Smith, could you just tell me if your daughter is in year 7, 8, 10, 11 or 13?'

How about a patient going to have an operation. 'Oh hello Mr Jones, I have 4 Mr Joneses coming in today. Are you having your tonsils removed, your leg removed or a hair transplant?' Not the best way to give your patients' confidence that you know what you are doing!

Therefore, it is important that every single record in a database has something to uniquely identify it and this is called the 'Primary Key' or sometimes the 'Key Field'.

database field

When you started school, you were given a 'student ID' or an 'office number' (primary key). This would enable all of the girls with the surname Smith to be identified independently.

When patients go into hospital, they are given a patient number (primary key). This means that any treatment can be recorded on their record and they will be given the right operation.

When bank customers want to deposit or withdraw money they have to provide their bank account number (primary key). This enables the cashier to access their account details and process their request.

 

database field

 

Challenge: see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: Primary Key