Keys and relationships


Primary key (unique data)


Key fields are individual pieces of data that are unique (only appear once).

Key fields are used to differentiate one record from another.






In our patient's database, the key field is
 the Patient Id
Every patient has a different Id Number
We can identify each patient uniquely and correctly
Imagine if the doctor mixed two patients up and gave
 them the wrong medicine!!



Why is Patient Id suitable for the Key Field?

Only the Patient Id is suitable for use as the unique key field. 
Remember the key field MUST contain only data that CAN 
NEVER REPEAT.
 Look at the table below and think about it:





linking tables: relationships


What is a relationship?



A relationship is formed when our two tables are joined together.

Relationships make use of key fields and primary keys to allow 

the two tables to communicate with each other and share their data





Once the tables are linked together each one can read data from the other.

How do you form the relationship? (link the tables)

In order to link the tables we need to use a common field.

A common field is data that appears in BOTH tables.





No comments:

Post a Comment