Two apps, two kinds of store
A school canteen app records who bought which lunch. A music app records songs, photos, likes and friends.
Both keep data. But the data has a different shape. So they do not store it the same way.
Key words
| Word | What it means | Example |
|---|---|---|
| Database | an organised store of data that you can search | |
| Table | rows and columns holding one kind of thing | pupils |
| Relational database | tables linked by values they share | |
| Non-relational database | a store shaped to suit the data in it | |
| Document | one record with its own fields, which can be nested | |
| Key-value store | a store you search by one id |
The cells students fill in are left blank in this preview.
By the end of this lesson
Note
I can say when a relational database or a non-relational database is the better fit.
Starter
Have a go
Starter
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
A relational database links tables
A relational database keeps data in tables. Each table holds one kind of thing, such as pupils or lunches.
Tables share a value, so a lunch can point at the pupil who bought it. The data points relate to each other.
Try it: two linked tables
-- Each lunch holds a pupil_id. The query follows it to the pupil.
select pupils.name, lunches.item, lunches.price_pence
from lunches join pupils on pupils.pupil_id = lunches.pupil_id
order by lunches.lunch_id;
-- Try it: add where pupils.form = '9B' before the order line.Check
Have a go
Check
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.