One trip, three shapes
A school plans a trip. There are 5 students on 2 buses.
You can write this as a tree: trip, then buses, then students. You can write it as a web of links. Or you can write it as two lists that point at each other.
Each shape is a data model. Each one is good at something different.
Key words
| Word | What it means | Example |
|---|---|---|
| Data model | A plan for how data is organised and linked. | A tree, a web or tables |
| Hierarchical model | Data in a tree. Every item has one parent above it. | Folders inside folders |
| Network model | Data in a web of links. An item can have many parents. | A map of roads |
| Relational model | Data in tables that are linked by an id. | A students table and a trips table |
| Parent | The item above another item in a tree. | Bus A is the parent of Sam |
| Child | An item below a parent. | Sam is a child of Bus A |
| Record | One row of facts about one thing. | Sam, 16, trip 1 |
| Key | An id in a row that links it to a row in another table. | trip_id in the students table |
The cells students fill in are left blank in this preview.
Quick check: the tree
Have a go
Quick check: the tree
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
Network: a web of links
In a tree, an item has one parent. In real life that is not always true.
Sam is in the chess club and in the football club. Each club has many students. So Sam has two parents: the two clubs. In a network model an item can have many parents and many children.
Relational: tables with keys
In a relational model the data lives in tables. A table has rows and columns.
We do not write the trip name next to every student. We store the trip once. Each student holds a key, the id of their trip. The tables are linked by that key.
Relational: two tables
| Table | Columns | Example row |
|---|---|---|
| trips | id, place, price | 1, Alton Towers, 32.50 |
| students | id, name, trip_id (the key) | 1, Sam, 1 |
| The link | students.trip_id matches trips.id | Sam goes to Alton Towers |
The cells students fill in are left blank in this preview.