Database Management System · Unit 4 · 3 hrs
The Relational Data Model and Relational Database Constraints
Exam-focused notes for The Relational Data Model and Relational Database Constraints (Database Management System, CSC265): what the TU syllabus asks and how it has actually been tested, with 5 solved past questions from this unit.
The Relational Data Model and Relational Database Constraints in short
This unit introduces the relational model itself: the formal notation used to talk about relations, tuples and attributes, the constraints every relational database must satisfy, and how insert, delete and update operations can violate those constraints.
What this unit covers
- Relational Model Concepts
- Relational Model Constraints and Relational Database Schemas
- Update Operations, Transactions, and Dealing with Constraint Violations
Relational Model Concepts
2080 · 5 marks
What is relational model? Define the terms domain, attribute, tuple and relation. [5]
Show solved answerHide answer
Relational Model
Definition
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.
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 |
2080.1 · 5 marks
What is relational database? Explain different characteristic of a relation. Defain domain constraint. [5]
Relational Model Constraints and Relational Database Schemas
2078 · 5 marks
What is integrity? Explain different types of database integrity. [5]
2076 · 5 marks
Differentiate between Integrity and Security with example. [5]
2076 · 5 marks
Explain the use of primary and foreign key in DBMS with example. What is the role of foreign key? [5]
Make Unit 4 stick
Practice CSC265 with flashcards & quizzes