Topic module

Two-Table Databases and SQL

Implement two linked tables with referential integrity and read, explain and write required National 5 SQL operations.

Long-form learning
Concept to Risk to Memory to Check-up

How to study National 5 Computing Science

Move from functional requirements to designs and implementation, trace data and code carefully, and support testing and evaluation with evidence.

Core concepts

Concept 1

A relational solution at this level uses two linked tables and enforces referential integrity.

Exam cue: Trace FROM and join conditions before applying WHERE filters and ORDER BY.

Concept 2

SELECT, FROM and WHERE can use AND, OR, less than, greater than and equality; ORDER BY can sort on at most two fields.

Exam cue: Use a precise WHERE condition for UPDATE or DELETE so only intended records change.

Concept 3

INSERT adds, UPDATE changes and DELETE removes records; an equi-join matches equal key values across the two tables.

Risk pitfalls and guardrails

Omitting the join condition and producing every possible pair of rows.

Guardrail: Check option route, data type, valid boundary, loop condition, array index, identifier and expected output before committing to the response.

Confusing INSERT, UPDATE and DELETE.

Guardrail: Check option route, data type, valid boundary, loop condition, array index, identifier and expected output before committing to the response.

Using SQL features beyond the specified National 5 range as assumed requirements.

Guardrail: Check option route, data type, valid boundary, loop condition, array index, identifier and expected output before committing to the response.

Memory anchors

Referential integrity

Every foreign-key value must match an existing related primary-key value.

SELECT and FROM

Choose the output fields, then identify the table or tables supplying them.

WHERE

Filter records using the required comparisons joined by AND or OR.

ORDER BY

Sort query output by one or at most two stated fields.

Data changes

INSERT adds a record, UPDATE changes records and DELETE removes records.

Equi-join

Match a foreign key to its related primary key using equality.

Checkpoint rule

Do the check-up only after you can summarize each concept in one sentence and identify one dangerous pitfall from memory.

Knowledge Check (after reading)

Short check-up to confirm understanding of this module.

Check-up Questions

1-2 question checkpoint

For the same query, which sort order gives A to Z?

A query needs class then surname ordering. What design should record?

Answer all questions to submit.

Next step personalized recommendations

Continue learning

Move forward only after this module is stable.

What is Pass Harbor?

Completely free exam prep for 247 UK exams.

  • Practice questions
  • Flashcards
  • Study guides
  • Mock exams
  • No registration
  • No paywall
  • Start instantly
No more expensive exam prep. Quality study tools should be accessible to everyone.