9. Primary Key
A primary key is a field 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 Charlotte.
If there were nothing to uniquely identify the students' records, the secretary would have to search for all of the 'Charlotte 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? And if she is in year 7, which one of these five girls is she?'
How about a patient going to have an operation. 'Oh hello Mr Jones, I have 4 Mr Joneses having an operation today, can you tell me if yours is to remove your tonsils, your arm, put your leg in a cast or give you a hair transplant?'. I think that would be one very worried patient!
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'.
When you started school, you were given a 'student ID' or an 'office number' (primary key).
This enables all of the girls called Charlotte Smith to be recognised.
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.
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
Each record must have a primary key
The primary key must be unique to that record
You should be able to identify any record by its primary key
A primary key is required for 1NF