Designing a database table
About this lesson: Designing a database table
In short
A database table stores data about one kind of thing. Each column is a field; each row is a record. Tap each.

What you'll explore
- Tables, fields and records: Rows and columns
- A database table stores data about one kind of thing. Each column is a field; each row is a record. Tap each.
- Primary keys: One of a kind
- A primary key is a field whose value is different for every record, like a student ID. Add a key.
- Data types: Fit the type to the data
- Choose a data type for each field: text, integer, real, Boolean or date/time.
- Why design matters: What goes wrong?
- If the same data is typed over and over, mistakes creep in and updates are missed. Good design stores each fact once.
- Linking tables: Primary and foreign keys
- A foreign key is a field that refers to the primary key of another table. It links records without repeating data.
- Check yourself: Primary key
- A table of library members has fields Name, DateOfBirth, MemberID and Town.
Also in this lesson
- Step by step
- Watch out for these
- More than the lesson
- Stretch your brain
- Try it yourself
Words to know
- Database
- An organised, searchable collection of data.
- Table
- Data about one kind of thing, in rows and columns.
- Field
- One piece of information (a column).
- Record
- All the data about one item (a row).
- Primary key
- A field with a unique value for each record.
- Foreign key
- A field that links to another table's primary key.
Sources
- E. F. Codd (1970), "A Relational Model of Data for Large Shared Data Banks", Communications of the ACM
- Raspberry Pi Foundation, Isaac Computer Science: databases
- BBC Bitesize, GCSE Computer Science: databases
- Information Commissioner's Office: data minimisation
← Linear search and bubble sort · Asking questions with SQL →