The contact list with three Sams
Your phone has three contacts called Sam. One has two numbers. One changed number last year, and you never updated it.
A list like that is a mess, and it is tiny. Netheret will store thousands of requests, visits and fixes.
Before anyone writes code, the data needs a design: what is stored, how it links, and what counts as a valid value.
Key words
| Word | What it means | Example |
|---|---|---|
| Entity | A thing the app stores data about. It becomes a table. | Ticket |
| Attribute | One fact stored about an entity. It becomes a field. | priority |
| Primary key | A field that is different for every row. | id |
| Foreign key | A field that points at a row in another table. | company_id |
| Data dictionary | A table that describes every field: its type, size and rules. | |
| Data type | The kind of value a field holds. | whole number, text, date |
| Validation | Checking a value is sensible before it is stored. | |
| Normalisation | Splitting data into tables so each fact is stored once. |
The cells students fill in are left blank in this preview.
By the end of this lesson
Note
I can write a data dictionary entry with a data type and a validation rule.
Starter: last lesson
Have a go
Starter: last lesson
3 questionsAn ERD shows the tables and their links
An entity relationship diagram (ERD) shows each entity as a box and each link as a line.
The ends of a line show how many. One company has many tickets. Each ticket has many updates. A ticket may have no job, or several.
Each link is made by a foreign key. Ticket stores company_id, which points at one row in Company.
The Netheret ERD
erDiagram
Company |o--o{ User : "has customer contacts"
Company ||--o{ Ticket : "raises"
User ||--o{ Ticket : "raised_by"
User |o--o{ Ticket : "assigned_to"
Ticket ||--o{ TicketUpdate : "has"
User ||--o{ TicketUpdate : "writes"
Ticket |o--o{ Job : "may lead to"
Company ||--o{ Job : "is visited in"
User ||--o{ Job : "engineer for"
User ||--o{ Article : "writes"
Check: reading the ERD
Have a go
Check: reading the ERD
3 questionsMatch each entity to what it stores
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
A data dictionary describes every field
The ERD shows the shape. The data dictionary gives the detail a developer needs to build each table.
For each field, give its name, data type, size, rules and an example. Keep one naming convention (a fixed way to write names). Here, tables are written like TicketUpdate and fields like raised_by_id.
A field that may be empty is marked "can be empty", such as resolved_at before a fix.
Worked example: the Ticket table
| Field | Type | Rule | Example |
|---|---|---|---|
| id | Integer (whole number) | Primary key, numbered automatically | 7 |
| reference | Text, 8 | NTH- then 4 digits, unique | NTH-0007 |
| title | Text, 100 | Required, 5 to 100 characters | Printer offline |
| description | Text, 2000 | Required, up to 2000 characters | Shows error E3 since Monday |
| category | Text, 10 | One of `hardware`, `software`, `network`, `account`, `other` | hardware |
| priority | Text, 8 | One of `low`, `medium`, `high`, `critical` | high |
| status | Text, 8 | One of `new`, `open`, `waiting`, `resolved`, `closed`. Starts as `new`. | open |
| company_id | Integer | Foreign key to Company | 3 |
| raised_by_id | Integer | Foreign key to User | 12 |
| assigned_to_id | Integer | Foreign key to User, can be empty | 5 |
| tier | Integer | 1, 2 or 3. Starts as 1. | 2 |
| created_at | Date and time | Set by the app when saved | 2026-03-03 09:14 |
| updated_at | Date and time | Set by the app on every change | 2026-03-03 11:02 |
| resolved_at | Date and time | Can be empty. Set when status becomes resolved. | 2026-03-03 15:40 |
The cells students fill in are left blank in this preview.
Check: the data dictionary
Have a go
Check: the data dictionary
3 questionsThe design says how errors are handled
A form sends everything as text. So the back end must check each value, turn it into the right type, and explain any problem.
Plan four things. Validation rules: length, range, a value from a list. Type casting (turning the text "90" into the number 90). Limits on length, so a field cannot overflow. Messages that tell the user how to fix it.
Try it: check a new request
CATEGORIES = ["hardware", "software", "network", "account", "other"]
def check_request(title, category):
errors = []
title = title.strip()
if len(title) < 5 or len(title) > 100:
errors.append("Title: use 5 to 100 characters.")
if category not in CATEGORIES:
errors.append("Category: choose one from the list.")
return errors
print(check_request("Printer offline", "hardware"))
print(check_request("PC", "printer"))
# Add a third line: a good title with the category "account".
Make a free account to save your work and track your progress.
A common mistake
Warning
Many students think one big table is simpler. It is, for a day. Then a company moves, and its address must change in hundreds of tickets. Store each fact once. Company details live in Company; a ticket only stores company_id.
Your turn: check a job's length
A manager types how long a job will take. Finish check_duration so it gives back an empty string for a whole number of minutes from 15 to 480. For anything else, it gives back the message in the comment. Test 15, 480, 14, 481, an empty box and "ninety".
def check_duration(text):
# The job form sends the duration as text, such as "90".
# Give back "" when it is a whole number of minutes from 15 to 480.
# Otherwise give back exactly this message:
# "Enter a whole number of minutes from 15 to 480."
return None
Make a free account to save your work, or press Start lab to work through the whole lesson.
Normalisation: why updates have their own table
| Before | Problem | After |
|---|---|---|
| Ticket has fields update1, update2, update3 | A fourth update has nowhere to go | A TicketUpdate table, one row per update |
| Ticket stores the company name and phone | Change the phone and old tickets disagree | Company table, linked by company_id |
| Job stores the engineer's name | A renamed engineer appears twice | Job stores engineer_id, a link to User |
The cells students fill in are left blank in this preview.
Your turn: the full data design
Make the full Netheret data design. Part 1. Draw the ERD with all six entities: User, Company, Ticket, TicketUpdate, Job and Article. Show each link and how many. Part 2. Write a data dictionary for User, Company, TicketUpdate, Job and Article, the same way as Ticket. Use the fields from the class plan, such as role, text_size and high_contrast on User, and kind, scheduled_start and duration_minutes on Job. Part 3. Under each table, write one line in plain words for Netheret's managers.
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.
Exit quiz
Have a go