← IB Computer Science

Relational databases

Databases store data in an organized way so it can be queried and analysed. This unit covers why we move from a single flat file to a relational database made of linked tables, the keys that create those links, and the relationships between entities.

Slide 1 / 4

Flat file vs relational databases

One flat file vs several linked tablesFlat file — one table, data repeatsPatientOwnerOwner telRexJ Ray555-01BoJ Ray555-01SamM Fox555-02IvyJ Ray555-01"J Ray / 555-01" stored 3× → wasted space, inconsistencysplitRelational — linked tablesOwner1 · J Ray · 555-012 · M Fox · 555-02stored once eachPatientRex→1Bo→1Sam→2Ivy→1link by key → each fact stored onceFlat-file anomalies: insert, deletion and update — caused by repeated data.A relational database splits data into several linked entities to remove that repetition.
  • A flat file database stores everything in a single entity (table), which repeats data and wastes storage space.
  • Repeated data causes data inconsistency: when the same fact is stored many times, it is hard to know which copy is correct.
  • Flat files suffer from three anomalies: insert, deletion and update anomalies.
  • A relational database splits the data into several linked entities to reduce this repetition.

Check you've got it

0/4

1. In a veterinary flat file database, you cannot add a new vet's details until a patient and an owner also exist in the same record. Which anomaly is this?

2. What is a foreign key?

3. One vet can carry out many treatments, but each treatment is carried out by only one vet. What is the cardinality of this relationship?

4. A receipt must always be linked to at least one item that was bought. What does this describe?

Free revision content. Multiple-choice answers are marked instantly. Written answers are marked by AI on /free-mark.