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.
- Identify the arity and the domainsName each attribute and the set its values come from. This is the table schema.
- Selection filters rowsσ_condition(R) keeps exactly the tuples satisfying the condition. The arity does not change.
- Projection keeps columnsπ_{attrs}(R) drops the other components — and removes duplicate tuples, since the result is a set.
- 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.
- Selection on course = Maths keeps (Ann, Maths, A) and (Bo, Maths, C).
- Projection onto student gives {Ann, Bo}.
- Is {student} a key? Ann appears in two distinct tuples.
- 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.
- Forgetting that projection eliminates duplicates. A relation is a set, so repeated tuples collapse to one — real SQL differs here, which is why SELECT DISTINCT exists.
- Assuming a key must be a single attribute. Composite keys of two or more attributes are common and often necessary.
- Confusing the arity of the relation with the number of tuples. Arity is the number of columns.
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.
- 1Reflexive, symmetric, antisymmetric & transitive
- 2Checking properties for a given relation
- 3Composition R∘S & inverse R⁻¹
- 4Matrix & digraph representations
- 5Reflexive & transitive closures
- 6Relations as subsets of A × B
- 7Powers Rⁿ & reachability
- 8Warshall’s transitive closure algorithm
- 9Counting relations with a given property
- 10Union, intersection & complement of relations
- 11n-ary relations & the relational data model
- 12Restricting a relation to a subset
- 13Symmetric closure vs transitive closure
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 →