Tables, records and fields, data types, primary and foreign keys, why linked tables beat one big table, and how a program holds records in a 2D array.
What you will learn
- Name the parts of a database table
- Choose a data type for a field
- Pick out primary and foreign keys
- Explain redundancy and inconsistency
- Read records held in a 2D array
Tables, records and fields
A database is an organised, permanent store of data that can be searched, sorted and updated.
The data sits in tables.
Table: Film
| FilmID | Title | Genre | Year |
|---|---|---|---|
| 1 | Silver River | Drama | 2011 |
| 2 | Paper Comet | Family | 2019 |
| 3 | Quiet Engine | Drama | 2004 |
- A record is one row: everything stored about one film. This table has 3 records.
- A field is one column: one piece of data stored for every record. This table has 4 fields.
- Every field has a data type: integer, real, Boolean, character, string or date. Year is an integer; Title is a string.
The rest of this lesson and its 9 practice questions are locked.
In this lesson
- Tables, records and fields
- Keys and linked tables
- Records in a program
- Try it: Find the keys
9 practice questions, marked as you go; about 25 minutes in all.
Key terms
Database, Tables, Record, Field, Primary key, Relational database, Foreign key, Once, Data redundancy, Data inconsistency
In this unit: Databases and SQL
Tables, records and fields, primary and foreign keys, why linked tables beat one big table, SQL queries over one or two tables, changing data with INSERT, UPDATE and DELETE, and reading and writing CSV files.
- Relational databases and records
- SQL queries
- Changing data and files
- Writing SQL