OCR H446 A Level Computer Science · 1.3 Exchanging Data
Stretch tasks Databases
Quiz Challenge
A quiz game against four computer players, then short and long written answers.
- Quiz Blitz12 questions against the clock
- Quick Fire4 short answers
- Big Think2 long answers
About 20 minutes
This or That
Pixel the cat asks 8 questions. Each has two answers: pick the right one.
- Two answers to every question
- A fish treat for every right answer
- Streaks win Pixel shades, then a party hat
About 4 minutes
Memory Match
Flip the cards two at a time to match each term card to its meaning card.
- 12 cards: each term has a meaning
- One peek at every card
- Combo points for pairs found in a row
6 pairs, about 4 minutes
Sort It
Sort each statement into the right box, like the tick box tables in the exam.
- 12 cards to sort into 4 boxes
- Drag a card, tap a box or press its number
- Combo points for cards sorted in a row
12 cards, about 4 minutes
Code Word
Guess the lesson's secret words. Every guess shows which letters are right.
- A clue for every word
- Tiles turn green, amber or grey after each guess
- Fewer guesses win more points
3 words, about 4 minutes
Link Up
12 tiles hide 3 groups of 4. Work out what links them.
- Pick four tiles that belong together
- Four slips and the round is over
- Fewer slips win more points
3 groups, about 3 minutes
Bug Hunt
Two statements are true and one has a bug. Catch the bug before it gets away.
- Three statements in every round
- Tap the one with the mistake
- Streaks win bonus points
5 rounds, about 4 minutes
Brain games
Train your brain on this lesson
Logic, memory and speed, built from this lesson's own key ideas. Win up to three diamonds in each game.
Odd One Out
Four tiles: three share a link and one does not. Spot the odd one out, then see what links the rest.
- Three belong together, one does not
- A hint shows the link, for fewer points
- Quick answers and streaks win more
8 rounds, about 3 minutes
Memory Flash
Study the term cards, then they flip over. Find the card that goes with each clue, from memory.
- Three levels: 3, 4 and 6 cards
- Two tries to find each card
- Streaks win bonus points
3 levels, about 4 minutes
Fact or Fib
Statements fly in one at a time. Is each one a fact or a fib? Decide fast.
- Swipe, tap or use the arrow keys
- Every fib comes with its fix
- Streaks multiply your points
12 statements, about 3 minutes
The final challenge
City Run
Race a robot cat on inline skates through a neon cyber city, from Neon Station to the Hyper Tunnel. Every question is a row of neon gates across the tracks: skate through the one with the right answer, dodge the trains and barriers, and grab diamonds.
- 20 questions from this lesson, in four parts of the city
- Swipe, tap or use the arrow keys
- Dodge trains and holograms, and jump crates and cones
20 questions, about 6 minutes
Bonus challenge
Neon Roll
Roll a glowing ball down an endless neon slope, past towers lit up with neon signs of Pixel the cat. Steer, jump the gaps and dodge the blocks. Questions from this lesson wait at gates along the way: every right answer keeps the ball rolling.
- Questions from this lesson at every gate
- Hold the arrow keys or a side of the slope to steer
- 8 right answers win two diamonds, 15 win three
Endless, about 5 minutes
The games need JavaScript. Every question is below, with the answers at the end.
Databases: the questions
Quiz Challenge, round 1: Quiz Blitz
Which key links one table to another?
- Secondary key
- Composite key
- Foreign key
- Primary key
How is a many to many relationship implemented?
- With a foreign key in each of the two tables
- By merging the two tables
- By making both primary keys composite
- With a linking table holding foreign keys to both tables
A table in third normal form has no transitive dependencies.
- True
- False
A table has a composite key and a field that depends on only part of it. Which normal form does it break?
- Second normal form
- First normal form
- Third normal form
Which THREE anomalies does normalisation remove?
Tick 3.
- Indexing anomalies
- Sorting anomalies
- Update anomalies
- Insertion anomalies
- Deletion anomalies
Order these clauses as they appear in an SQL query.
Number these 1 to 4.
- FROM
- WHERE
- ORDER BY
- SELECT
What does this query return?
SELECT Name FROM Students WHERE Year = 12 AND Grade >= 7;- Every student in Year 12
- Every student with a grade of exactly 7
- The number of Year 12 students
- The names of Year 12 students with a grade of at least 7
UPDATE Students SET Grade = 9 with no WHERE clause changes only the first row.
- True
- False
Which ACID property means a committed change survives a power cut?
What is the cost of adding an index to a field?
- Inserts, updates and deletes become slower
- Searches on the field become slower
- The table can no longer be sorted
- The field can no longer be a key
Two transactions each wait for a record the other has locked. What is this?
- A transitive dependency
- A deletion anomaly
- Deadlock
- Atomicity
Which ACID property means every operation in a transaction succeeds, or none do?
- Durability
- Isolation
- Consistency
- Atomicity
Quiz Challenge, round 2: Quick Fire
Explain why a database designer normalises tables. [2 marks]
Describe the difference between a primary key and a foreign key. [2 marks]
Explain why indexing every field of a table is a bad idea. [2 marks]
Explain what isolation means for database transactions. [2 marks]
Quiz Challenge, round 3: Big Think
Describe the first three normal forms. [6 marks]
Explain how the ACID properties protect a bank transfer between two accounts. [4 marks]
This or That: tick the right answer
Where does the foreign key go in a one to many relationship?
- On the one side
- On the many side
A field holds 'Maths, Physics, Art' for one student. Which normal form does this break?
- Third
- First
Which makes searching on a field faster?
- A foreign key on that field
- An index on that field
Which SQL clause filters groups after GROUP BY?
- HAVING
- WHERE
What happens if DELETE FROM Students has no WHERE clause?
- Nothing is deleted
- Every row is deleted
Which concurrency control avoids deadlock?
- Record locking
- Timestamp ordering
Which ACID property keeps concurrent transactions from interfering?
- Isolation
- Durability
Why might an analytics system denormalise its tables?
- To remove redundancy
- To make complex reads faster
Memory Match: match each term to its meaning
| Term | Meaning |
|---|---|
| A Composite key | 1 Resolves a many to many relationship |
| B Foreign key | 2 Committed changes survive a crash |
| C Linking table | 3 Links to the primary key of another table |
| D Transitive dependency | 4 Two transactions each waiting for the other's lock |
| E Deadlock | 5 A primary key made of two or more fields |
| F Durability | 6 A non key field depending on another non key field |
Sort It: tick one box in each row
Which ACID property does each statement describe?
| Statement | Atomicity | Consistency | Isolation | Durability |
|---|---|---|---|---|
| A failed transaction is rolled back completely | ||||
| One transaction cannot see another's unfinished changes | ||||
| The database moves from one valid state to another | ||||
| Every operation in a transaction succeeds, or none do | ||||
| A crash just after a commit loses nothing | ||||
| A transaction cannot leave data that breaks a constraint | ||||
| Committed changes survive a power cut | ||||
| Changes are written to non volatile storage | ||||
| A transfer cannot debit one account and stop before the credit | ||||
| The result matches running them one at a time in some order | ||||
| Concurrent transactions do not interfere | ||||
| Every rule and constraint still holds afterwards |
Code Word: write the word that fits each clue
Something data is stored about, which becomes a table. (6 letters)
A structure that maps field values to records to speed up searches. (5 letters)
Two transactions each waiting for a record the other has locked. (8 letters)
Link Up: find the three groups
These 12 tiles make 3 groups of 4. Write each group in the table, and what links its tiles.
- GROUP BY
- Consistency
- Isolation
- HAVING
- Secondary
- SELECT
- Composite
- Foreign
- WHERE
- Atomicity
- Primary
- Durability
| Group | The 4 tiles | What links them |
|---|---|---|
| Group 1 | ||
| Group 2 | ||
| Group 3 |
Bug Hunt: tick the statement that is wrong
In each set, two statements are true and one has a mistake in it.
- A foreign key holds the primary key of another table.
- A many to many relationship can be built directly with two foreign keys.
- A primary key uniquely identifies each record.
- Third normal form allows one non key field to depend on another.
- First normal form has no repeating groups.
- Second normal form removes partial dependencies on a composite key.
- An index makes searches on a field faster.
- Every index must be updated when records change.
- An index makes inserts and updates faster too.
- Isolation means a transaction is saved even if the power fails.
- Durability means committed changes survive a crash.
- Atomicity means all of a transaction happens or none of it does.
- WHERE filters rows before they are grouped.
- HAVING filters the groups made by GROUP BY.
- DELETE with no WHERE clause deletes only the first row.
Brain game: Odd One Out
Three tiles in each set share a link. Tick the odd one out, then write what links the other three.
- GROUP BY
- HAVING
- SELECT
- Atomicity
What links the other three?
- Consistency
- Atomicity
- Primary
- Durability
What links the other three?
- Secondary
- Composite
- WHERE
- Primary
What links the other three?
- GROUP BY
- SELECT
- WHERE
- Atomicity
What links the other three?
- Isolation
- SELECT
- Atomicity
- Durability
What links the other three?
- HAVING
- Secondary
- Foreign
- Primary
What links the other three?
Brain game: Memory Flash, on paper
Which term means this? Write your answer from memory.
A non key field depending on another non key field
Resolves a many to many relationship
Committed changes survive a crash
Links to the primary key of another table
Two transactions each waiting for the other's lock
A primary key made of two or more fields
Brain game: Fact or Fib
Tick Fact if the statement is true and Fib if it is not.
Isolation means a transaction is saved even if the power fails.
- Fact
- Fib
An index makes inserts and updates faster too.
- Fact
- Fib
Third normal form allows one non key field to depend on another.
- Fact
- Fib
An index makes searches on a field faster.
- Fact
- Fib
DELETE with no WHERE clause deletes only the first row.
- Fact
- Fib
Durability means committed changes survive a crash.
- Fact
- Fib
A many to many relationship can be built directly with two foreign keys.
- Fact
- Fib
UPDATE Students SET Grade = 9 with no WHERE clause changes only the first row.
- Fact
- Fib
Atomicity means all of a transaction happens or none of it does.
- Fact
- Fib
A primary key uniquely identifies each record.
- Fact
- Fib
A foreign key holds the primary key of another table.
- Fact
- Fib
WHERE filters rows before they are grouped.
- Fact
- Fib
City Run
City Run is a race through a neon cyber city, played on screen. It asks 20 of the questions above, from the quiz, This or That, Memory Flash and Fact or Fib.
Neon Roll
Neon Roll is a ball rolling down an endless neon slope, played on screen. Every right answer keeps it rolling. It asks the questions above, from the quiz, This or That, Memory Flash and Fact or Fib.
Answers
Round 1: Quiz Blitz
- Foreign key A foreign key is a field holding the primary key of another table, which forms the link.
- With a linking table holding foreign keys to both tables A many to many relationship cannot be built directly, so a linking table sits between the two.
- True In 3NF no non key attribute depends on another non key attribute: each depends on the key, the whole key and nothing but the key.
- Second normal form 2NF demands that every non key attribute depends on the whole of the primary key.
- Update anomalies; Insertion anomalies; Deletion anomalies Normalisation stops copies of a fact disagreeing, records needing unrelated data, and deletions destroying unrelated facts.
- SELECT → FROM → WHERE → ORDER BY Choose the fields, name the table, filter the rows, then sort the result.
- The names of Year 12 students with a grade of at least 7 Both conditions must be true, and >= includes 7 itself.
- False Without WHERE, UPDATE changes every row in the table, one of the most damaging mistakes in practice.
- durability Committed changes are written to non volatile storage, so they survive a crash.
- Inserts, updates and deletes become slower The index must be updated on every write, and it takes extra storage.
- Deadlock Neither can go on until the other lets go, so both are stuck.
- Atomicity Atomicity treats the transaction as one indivisible unit, so a transfer cannot stop halfway.
Round 2: Quick Fire
- It removes redundancy, so each fact is stored once
- It prevents update, insertion and deletion anomalies
- It saves storage
Model answerNormalising removes redundancy, so each fact is stored only once, which prevents update, insertion and deletion anomalies.
- A primary key uniquely identifies each record
- A foreign key holds the primary key of another table, linking them
Model answerA primary key uniquely identifies each record in its table. A foreign key is a field that holds the primary key of another table, which links the two tables.
- Every index must be updated on each write, so writes slow down
- Each index takes extra storage
- Fields that are rarely searched gain nothing
Model answerEvery index must be updated whenever a record is inserted, changed or deleted, so writes become slower, and each index takes extra storage.
- Transactions running at the same time do not interfere
- The result is as if they had run one after another
Model answerTransactions running at the same time do not interfere with each other, so the result is the same as if they had run one after another.
Round 3: Big Think
- 1NF has no repeating groups
- In 1NF every field holds a single atomic value
- In 2NF every non key attribute depends on the whole key
- 2NF removes partial dependencies on part of a composite key
- In 3NF no non key attribute depends on another non key attribute
- The key, the whole key and nothing but the key
Model answerIn first normal form there are no repeating groups and every field holds a single atomic value. In second normal form the table is in 1NF and every non key attribute depends on the whole key, so there are no partial dependencies on part of a composite key. In third normal form the table is in 2NF and no non key attribute depends on another non key attribute, so there are no transitive dependencies: every attribute depends on the key, the whole key and nothing but the key.
- Atomicity: the debit and the credit both happen, or neither does
- Consistency: the database moves from one valid state to another
- Isolation: transfers running at the same time cannot interfere
- Durability: once committed, the transfer survives a crash
Model answerAtomicity means the debit and the credit both happen or neither does, so money cannot vanish halfway. Consistency means the database moves from one valid state to another, with the total balance unchanged. Isolation means two transfers running at the same time cannot interfere with each other. Durability means that once the transfer is committed it survives a crash or power cut.
This or That
- On the many side Each record on the many side holds the key of the one record it belongs to.
- First 1NF needs atomic values, one value per field. A list in a field is a repeating group.
- An index on that field An index maps field values to record locations, so the whole table need not be scanned.
- HAVING WHERE filters rows before grouping. HAVING filters the groups that GROUP BY produces.
- Every row is deleted Without a WHERE clause the command applies to every row, which is why it is so dangerous.
- Timestamp ordering Timestamps order the transactions, so none waits forever, though some are restarted. Locks can leave two transactions waiting for each other.
- Isolation Isolation makes the result match some sequential order. Durability is about surviving a crash.
- To make complex reads faster Fewer tables mean fewer joins, so queries run faster. The price is the redundancy that normalisation removes.
Memory Match
- A 5 Composite key: A primary key made of two or more fields
- B 3 Foreign key: Links to the primary key of another table
- C 1 Linking table: Resolves a many to many relationship
- D 6 Transitive dependency: A non key field depending on another non key field
- E 4 Deadlock: Two transactions each waiting for the other's lock
- F 2 Durability: Committed changes survive a crash
Sort It
- Atomicity A failed transaction is rolled back completely Rolling back everything keeps the transaction all or nothing.
- Isolation One transaction cannot see another's unfinished changes Unfinished work stays hidden from other transactions.
- Consistency The database moves from one valid state to another Consistency means every rule still holds after the transaction.
- Atomicity Every operation in a transaction succeeds, or none do All or nothing is atomicity.
- Durability A crash just after a commit loses nothing Once committed, the change is safe whatever happens next.
- Consistency A transaction cannot leave data that breaks a constraint Consistency keeps the data valid.
- Durability Committed changes survive a power cut Durability means a commit is permanent.
- Durability Changes are written to non volatile storage Writing to non volatile storage is how durability is guaranteed.
- Atomicity A transfer cannot debit one account and stop before the credit Atomicity makes the transfer one indivisible unit.
- Isolation The result matches running them one at a time in some order Isolation makes concurrent transactions behave as if they ran in sequence.
- Isolation Concurrent transactions do not interfere Isolation keeps transactions running at the same time apart.
- Consistency Every rule and constraint still holds afterwards A transaction may not leave the database breaking its own rules.
Code Word
- ENTITY Something data is stored about, which becomes a table.
- INDEX A structure that maps field values to records to speed up searches.
- DEADLOCK Two transactions each waiting for a record the other has locked.
Link Up
- SQL keywords SELECT; WHERE; GROUP BY; HAVING
- ACID properties Atomicity; Consistency; Isolation; Durability
- Types of key Primary; Foreign; Composite; Secondary
Bug Hunt: the wrong statement, and why
- A many to many relationship can be built directly with two foreign keys. It needs a linking table holding foreign keys to both tables.
- Third normal form allows one non key field to depend on another. That is a transitive dependency, which 3NF removes: every non key field depends only on the key.
- An index makes inserts and updates faster too. Every write must also update the index, so inserts, updates and deletes get slower.
- Isolation means a transaction is saved even if the power fails. That is durability. Isolation means concurrent transactions do not interfere with each other.
- DELETE with no WHERE clause deletes only the first row. Without WHERE, DELETE removes every row in the table.
Odd One Out
- Atomicity is the odd one out: it goes with ACID properties. The other three: SQL keywords.
- Primary is the odd one out: it goes with Types of key. The other three: ACID properties.
- WHERE is the odd one out: it goes with SQL keywords. The other three: Types of key.
- Atomicity is the odd one out: it goes with ACID properties. The other three: SQL keywords.
- SELECT is the odd one out: it goes with SQL keywords. The other three: ACID properties.
- HAVING is the odd one out: it goes with SQL keywords. The other three: Types of key.
Memory Flash
- Transitive dependency A non key field depending on another non key field
- Linking table Resolves a many to many relationship
- Durability Committed changes survive a crash
- Foreign key Links to the primary key of another table
- Deadlock Two transactions each waiting for the other's lock
- Composite key A primary key made of two or more fields
Fact or Fib
- Fib Isolation means a transaction is saved even if the power fails. The fix: That is durability. Isolation means concurrent transactions do not interfere with each other.
- Fib An index makes inserts and updates faster too. The fix: Every write must also update the index, so inserts, updates and deletes get slower.
- Fib Third normal form allows one non key field to depend on another. The fix: That is a transitive dependency, which 3NF removes: every non key field depends only on the key.
- Fact An index makes searches on a field faster.
- Fib DELETE with no WHERE clause deletes only the first row. The fix: Without WHERE, DELETE removes every row in the table.
- Fact Durability means committed changes survive a crash.
- Fib A many to many relationship can be built directly with two foreign keys. The fix: It needs a linking table holding foreign keys to both tables.
- Fib UPDATE Students SET Grade = 9 with no WHERE clause changes only the first row. The fix: Without WHERE, UPDATE changes every row in the table, one of the most damaging mistakes in practice.
- Fact Atomicity means all of a transaction happens or none of it does.
- Fact A primary key uniquely identifies each record.
- Fact A foreign key holds the primary key of another table.
- Fact WHERE filters rows before they are grouped.

