Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

6.10 (3 of 3): Drawing data models

The whole lesson, free. Read it and have a go at the activities. To work the tasks and labs in the real lesson, press Start lab, with no account needed.

45 minutes

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

Draw it before you build it

A builder draws a plan before the first brick. A programmer draws the data before the first line of code.

A good drawing lets a team agree in five minutes. Without it, they talk for an hour and still disagree.

Today you draw all three data models.

Key words

WordWhat it meansExample
BlockA box in a drawing that shows one item.A box with Park in it
ArrowA line with a point that joins two blocks.Station to Park
LabelWords that say what a block or arrow is.5 min
ParentThe block an arrow comes from, above its child.Head teacher
ChildThe block that an arrow points to.Head of Science
Hierarchical modelA tree where every item has one parent.Folders
Network modelA web where an item can have many parents.Bus routes
Relational modelTables linked by keys.Clubs and members
KeyA column that links a row to a row in another table.club_id
RowOne record in a table.1, Sam, 1
ColumnOne kind of fact in a table.name

The cells students fill in are left blank in this preview.

A hierarchical model, drawn

A tree: arrows labelled "manages" go from "Head teacher" to "Head of Science" and "Head of English", from "Head of Science" to "Mr Khan" and from "Head of English" to "Ms Evans".A tree: arrows labelled "manages" go from "Head teacher" to "Head of Science" and "Head of English", from "Head of Science" to "Mr Khan" and from "Head of English" to "Ms Evans".

Quick check: read the drawing

Have a go

Quick check: read the drawing

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Rules for trees and webs

Draw one block for each item. Draw an arrow for each link. Put a label on a block to name it. Put a label on an arrow to say what the link means.

In a tree, arrows go from parent to child, and each block gets one arrow in. In a network, a block can get many arrows in. In the bus map below, a bus goes from the start of an arrow to its point. School gets two arrows in.

A network model, drawn

A network of bus stops: arrows go from "Station" to "Park" (5 min) and to "School" (10 min), and from "Park" to "School" (4 min) and to "Mall" (8 min), so School gets two arrows in.A network of bus stops: arrows go from "Station" to "Park" (5 min) and to "School" (10 min), and from "Park" to "School" (4 min) and to "Mall" (8 min), so School gets two arrows in.

Draw a tree

Complete the tree of a school. Under Head of Science add two teachers. Under Head of English add two teachers. Give every arrow the label manages. Give every block a name. The first lines are done for you.

flowchart TD
  head[Head teacher] -->|manages| sci[Head of Science]
  head -->|manages| eng[Head of English]
  %% add the teachers below

Make a free account to save your work, or press Start lab to work through the whole lesson.

Draw a network

Draw the bus stops of a town as a network. The stops are Station, Park, School and Mall. A bus goes from Station to Park in 5 minutes. A bus goes from Park to School in 4 minutes. A bus goes from School to Mall in 6 minutes. A bus goes from Station to School in 10 minutes. Draw every link as an arrow and write its time on it. Which stop gets two arrows in?

flowchart LR
  station[Station] -->|5 min| park[Park]
  %% add the other three arrows below

Make a free account to save your work, or press Start lab to work through the whole lesson.

Rules for tables

You draw a relational model as tables. Write the name of the table on top. Put the columns across the top row. Put each record in one row below.

Mark the key column. It links a row to a row in the other table. Look at the two tables below. In the members table, club_id 1 points to Chess.

The clubs table

clubs.idclubs.name
1Chess
2Music

The cells students fill in are left blank in this preview.

The members table

members.idmembers.namemembers.club_id (key)
1Sam1
2Aisha2
3Leo1

The cells students fill in are left blank in this preview.

Match the part of the drawing

Have a go

Loading…

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Watch: drawing data models

Press Play on the short film below. It shows the three parts of a drawing, then a tree, a network and two tables.

Film: drawing data models

Drawing data models

Every scene, as text

  1. Draw it before you build it. A builder draws a plan before the first brick. A programmer draws the data before the first line of code. A good drawing lets a team agree in five minutes (good: a drawing first). Without it, they talk for an hour and still disagree (bad: no drawing).
  2. Rules for trees and webs. Station, with an arrow to Park and 5 min on the arrow (Park: a block, one item; Station to Park: an arrow; 5 min: a label on the arrow). Put a label on an arrow to say what the link means.
  3. A hierarchical model, drawn. Head teacher, with arrows down to Head of Science and Head of English; Head of Science, with an arrow down to Mr Khan; Head of English, with an arrow down to Ms Evans; every arrow labelled manages (Head teacher: the parent; Head of English: a child; manages: what each link means). An arrow comes from a parent and points to its child.
  4. Myth (false): a block in a tree can have two parents. That is not true: each block in a tree gets one arrow in. In a network, a block can get many arrows in. A bus map: Station to Park, 5 min; Station to School, 10 min; Park to School, 4 min; Park to Mall, 8 min (bus routes: a network model; School: two arrows in).
  5. Rules for tables. The clubs table: id, name; 1, Chess; 2, Music (clubs: the table's name, on top; id, name: the columns, top row). The members table: id, name, club_id (key); 1, Sam, 1; 2, Aisha, 2; 3, Leo, 1 (club_id: the key column, marked; 1, Sam, 1: one row, one record), with an arrow from Sam's club_id to Chess.

Extra: The same tables as an ER picture

An ER picture: a "CLUBS" box with int id PK and string name, a "MEMBERS" box with int id PK, string name and int club_id FK, and a line labelled "has" from one club to many members.An ER picture: a "CLUBS" box with int id PK and string name, a "MEMBERS" box with int id PK, string name and int club_id FK, and a line labelled "has" from one club to many members.

Extra: Try it: build the tables in SQL

Code: sql
-- PRIMARY KEY (PK): a column with a different value in every row.
-- FOREIGN KEY (FK): a column that holds the primary key of a row in another table.
CREATE TABLE clubs (id INTEGER PRIMARY KEY, name TEXT);
CREATE TABLE members (id INTEGER PRIMARY KEY, name TEXT, club_id INTEGER,
  FOREIGN KEY (club_id) REFERENCES clubs(id));
INSERT INTO clubs VALUES (1, 'Chess');
INSERT INTO members VALUES (1, 'Sam', 1);
SELECT * FROM members;

-- Add one more club and one more member, then run it again.

Draw the tables

A library has books and authors. One author writes many books. A book has one author. Draw the two tables. Write the name of each table, then its columns, then two rows of example data. The authors table has id and name. The books table has id, title and author_id. Mark author_id as the key column and say which table it points to.

A teacher marks this in a college. Nothing you write here is kept: it goes when you leave the page.

Make a free account to save your work, or press Start lab to work through the whole lesson.

Your turn: tables from a picture

Have a go

Your turn: tables from a picture

4 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Final check

Have a go

Final check

5 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Remember

Important

Tree and network: blocks, arrows and labels. Relational: tables, rows, columns and labels. Always mark the key column and say what each link means.

Teach this lesson with your class

On a college account your students work the tasks and the labs as well, and every mark is kept for you.