QED
Relations · step 11 of 13

n-ary relations & the relational data model

An n-ary relation is a subset of A₁ × A₂ × … × Aₙ — a set of n-tuples, which is exactly a database table with n columns. Codd’s relational model builds directly on this: selection filters rows by a condition, projection keeps chosen columns, and join combines two tables on matching attributes. A key is a set of attributes whose values determine a tuple uniquely.

Unlimited questions · marked criterion by criterion · no card needed

Method: how to approach it

The order below is what examiners expect to see, and each step carries its own marks.

  1. Identify the arity and the domainsName each attribute and the set its values come from. This is the table schema.
  2. Selection filters rowsσ_condition(R) keeps exactly the tuples satisfying the condition. The arity does not change.
  3. Projection keeps columnsπ_{attrs}(R) drops the other components — and removes duplicate tuples, since the result is a set.
  4. Join matches on shared attributesThe natural join pairs tuples agreeing on all common attributes, producing tuples over the union of the two schemas.

Worked example

For Enrol(student, course, grade) = {(Ann, Maths, A), (Ann, Physics, B), (Bo, Maths, C)}, compute π_{student}(σ_{course = Maths}(Enrol)) and say whether {student} is a key.

  1. Selection on course = Maths keeps (Ann, Maths, A) and (Bo, Maths, C).
  2. Projection onto student gives {Ann, Bo}.
  3. Is {student} a key? Ann appears in two distinct tuples.
  4. So student alone does not determine the tuple.

Answer. {Ann, Bo}; {student} is not a key, but {student, course} is — it determines the grade uniquely.

Where marks get dropped

These are the specific errors that cost credit on n-ary relations & the relational data model questions — QED's rubric penalises each of them separately.

Practise this until it is automatic

Unlimited fresh questions

QED generates new n-ary relations & the relational data model problems on demand at warm-up, exam and challenge level, so you can drill this one skill until it stops costing you marks.

Marked like an examiner

Every answer is scored against a point-by-point rubric with partial credit, so you see exactly which step of the method broke down — not just a tick or a cross.

Answer in real notation

A one-tap symbol palette, a visual equation editor and a truth-table builder — or photograph your handwritten working and QED converts it to LaTeX.

Saved to your library

Every question you generate is kept and re-takeable as a timed exam, and your Relations mastery is tracked so you know when this is exam-ready.

n-ary relations & the relational data model — frequently asked questions

How is a binary relation a special case?

It is the n = 2 case: a two-column table. Everything about domains, ranges and composition carries over, with composition corresponding to a join followed by a projection.

What makes something a primary key?

A minimal set of attributes that uniquely determines each tuple. Minimality matters: {student, course, grade} determines the tuple but is not minimal if {student, course} already does.

Is SQL exactly the relational algebra?

Close but not identical. SQL tables are multisets and allow NULLs, both of which break the clean set-theoretic model — which is why query results can surprise you.

The rest of Relations

Properties of relations, composition, and representations. Each subtopic below has its own method, worked example and mark-losing traps.

Ready to make n-ary relations & the relational data model exam-proof?

Generate your first questions free — no card, no setup, no personal data stored. Practise until the method is second nature.

Start practising free →