learning-it by example

Back to the video

Data Modelling Basics: Entities, Keys, Relationships

With foreign key checks off, SQLite accepted a repair for bike 99, which does not exist.

Video #250 ยท Data modelling

Steps in the video

  1. 0:00 A repair for a bike that does not exist
  2. 0:33 The idea
  3. 1:06 Setup
  4. 1:25 Customer and bike
  5. 1:58 Mechanic and repair
  6. 2:25 Made-up rows, and the connection
  7. 2:53 The diagram, from the schema
  8. 3:28 Three attempts and a join
  9. 3:48 Run the diagram
  10. 4:38 What this does not show
  11. 5:03 Mistakes to avoid
  12. 5:43 My take and next steps
  13. 6:10 Recap

Files

  • erd.py (20 lines)
  • run.py (41 lines)
  • schema.py (47 lines)

Download the code (zip)

Tested with

Python 3.12.15

What this does not show

A made-up four-table bike shop in SQLite; it does not cover many-to-many relationships, deletes or a graphical diagram.

Sources

Learning IT by Example.