Files and databases · GCSE · OCR J277 2.2.3, AQA 8525 3.7.1 · about 15 min
Tables, records, fields, primary and foreign keys, and avoiding redundancy.
[1 mark]In a database table, what is a record?
[1 mark]What is a primary key?
[1 mark]In the runs table, robot_id holds the primary key of a record in the robots table. What is robot_id in runs?
[1 mark]Ada's colour is typed into every one of her runs. What is this called?
[1 mark]Why is storing Ada's colour once, in a robots table, better?
[1 mark]Why would a robot's name make a poor primary key?
Using logbook.open_db(), print one line for every run, in run order, in the form run 1 by Ada: wall 42.0 cm. Look each robot's name up through the robot_id foreign key; do not type the names into your program.
# the two lines every program starts with: the commands, then the robot from bugbot import * connect() import logbook db = logbook.open_db()
Plan your program here, then type it in and press Run.
tasks table with a primary key and a description of each task, and make runs use a foreign key to it.runs could never be a primary key, and why?