CSC265 ยท 2080 ยท 5 marks
What is relational model? Define the terms domain, attribute, tuple and relation.
What is relational model? Define the terms domain, attribute, tuple and relation. [5]
Quick answer
The relational model is a data model that represents data in the form of relations (tables). It was proposed by E.F. Codd and is the foundation of relational database management systems (RDBMS). In this model, all data is logically structured as two-dimensional tables consisting of rows and columns. SQL uses the terms table, row, and column for the formal relational model terms relation, tuple, and attribute respectively.
Relational Model
Definition
Key Terms
1. Domain
A domain is a set of atomic (indivisible) values from which the actual values of an attribute are drawn.
- Domain constraints specify that within each tuple, the value of each attribute A must be an atomic value from the domain dom(A).
- Data types associated with domains include:
- Numeric types: integer, short integer, long integer, float, double
- Other types: characters, Booleans, fixed-length strings, etc.
Example: The domain of an attribute "Age" could be the set of positive integers.
2. Attribute
An attribute is a named column of a relation that represents a specific property or characteristic of the entity being described.
- Each attribute A takes values from its corresponding domain dom(A).
- In SQL, attributes are referred to as columns.
Example: In a Student relation,
Sname,Sid, andAddressare attributes.
3. Tuple
A tuple is a single row in a relation that represents a single instance or record of the entity.
- An n-tuple
tin a relationr(R)is denoted as:
$$t = \langle v_1, v_2, \ldots, v_n \rangle$$
where $v_i$ is the value corresponding to attribute $A_i$.
- Both
t[Aแตข]andt.Aแตขrefer to the value $v_i$ in tupletfor attribute $A_i$. - In SQL, tuples are referred to as rows.
Example:
<101, "Ram", "Kathmandu">is a tuple in a Student relation.
4. Relation
A relation is a two-dimensional table with rows and columns used to represent data and the relationships among data.
- A relation
rdefined on a relation schemaR(Aโ, Aโ, ..., Aโ)is a set of n-tuples. - Each tuple in the relation contains one value for each attribute drawn from its domain.
- A relation must satisfy integrity constraints such as domain constraints, key constraints, and referential integrity constraints.
- In SQL, a relation is referred to as a table.
Example:
| Sid | Sname | Address |
|---|---|---|
| 101 | Ram | Kathmandu |
| 102 | Sita | Pokhara |
This table is a relation with 2 tuples and 3 attributes.
Summary Table
| Formal Term | SQL Equivalent | Meaning |
|---|---|---|
| Relation | Table | The entire two-dimensional table |
| Tuple | Row | A single record in the table |
| Attribute | Column | A property/field of the relation |
| Domain | Data Type | Set of valid values for an attribute |
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.