Relation (Database)
Context: FIT2094_MOC Β· the central object of the Relational Model Β· heading (schema) + body (tuples) Β· sized by degree and cardinality
Quick Revision
- π― Objective: a structured set of data β heading (schema) + body (tuples).
- π¦ Core Components: heading β body .
- β‘ Key Constraint: degree ( attributes, fixed) vs cardinality ( tuples, varies).
π Core
1. Two Parts
- Heading (schema) β β name + attributes, each from a domain.
- Body (instance) β β the current set of tuples, changing over time.
2. Tuple, Degree, Cardinality
- Tuple β ordered list .
- Degree β = number of attributes (heading property).
- Cardinality β = number of tuples (body property, fluctuates).
3. Writing a Relation
- Singular name β it denotes a set.
- PK underlined β .
Key identities:
βοΈ Core Decision Matrix
| Term | Meaning | Belongs to |
|---|---|---|
| heading | schema | structure |
| body | tuples | data |
| degree | # attributes | heading |
| cardinality | # tuples | body |
When It Flips: because the body is a set, no duplicate tuples and tuples/attributes are unordered (Relation Properties). An -degree relation is a subset of the Cartesian Product of its attribute domains β the n-ary Relation.
π Exam Execution Trace
Manual Execution Trace
CUSTOMER with 3 rows:
| Step / State | Quantity | Value |
|---|---|---|
| 0 (Init) | β | β |
| 1 | degree | 4 (attributes) |
| 2 | cardinality | 3 (tuples) |
| 3 | PK | custno (underlined) |
β οΈ Common Mistakes
- π‘ Degree fixed, cardinality varies β degree is a design-time schema property; cardinality is run-time data that changes as rows are inserted/deleted.
π§ Active Recall
Define the heading and body of a relation, and the terms degree and cardinality.
- Hint: Schema vs instance.
Answer
- Short answer: Heading = (structure); body = (data); degree = attributes; cardinality = tuples.
- Why: Fixed vs varying β degree from the heading, cardinality from the body.
How is a relation written, and how does it correspond to the n-ary relation?
- Hint: Singular + underlined PK.
Answer
- Short answer: Singular name, PK underlined; a degree- relation is a subset of the product of domains.
- Why: Same terms β degree (attributes) and cardinality (tuples) match the n-ary Relation.