The Relational Model
The Relational Model
Example:
Relation Instructor has the Attributes:
InstID, InstName, DeptName and Salary,
and the first Tuple represents instructor
Srinivasan, who works in the Computing
Science Department, has an Instructor
4 Attributes/columns
ID 10101, and a Salary of 65000.00.
12 Tuples/rows
Domain Examples
• InstID: Integers from [10000, 99999]
• DeptName: Elements from the set
{Biology, Comp. Sci., Elec. Eng.,
Finance, History, Music, Physics}
• Attribute Values must be atomic
A Key
• Is the Attribute, or set of Attributes,
that makes relation tuples unique. Department
• No two tuples have the same Key
• Sometimes it takes more than one attribute
to make a Key. For example:
Classroom(Building, Room, Capacity)
Table Names are shown in blue boxes. Primary Key Attributes are underlined.
Foreign Keys are shown with arrows.
1. The Relational Model Basic Concepts 14
Database Languages
A query language is a language used to extract data from a database.
For relational query languages, the output is a table/relation.
SQL – Structured Query Language: most widely used query language
• Example of a query to find physics instructors with a salary < 80000:
SELECT InstID, InstName FROM Instructor
WHERE DeptName = ‘Physics’ AND Salary < 80000;
Formal Query Languages based on Mathematics:
• Relational Algebra with Relations as variables, for example:
InstID, InstName (DeptName = ‘Physics’ ˄ Salary < 80000 (Instructor))
Relation Instance
• Content of a relation Instructor shown in SQL:
SELECT InstID, InstName, DeptName, Salary FROM Instructor;
Readings
• In Database Systems Concepts please read Chapters 1.1-1.6 & 2
• Pay special attention to the Summaries.
Student
Instructor
Advisor
Department
Instructor(InstID, InstName,
DeptName, Salary)
Advisor(StudID, InstID)
Department(DeptName, Building,
Budget)
Advisor(StudID, InstID)
Student Instructor
StudID InstID
Department(DeptName, Building,
Budget) StudName InstName
Birth DeptName
DeptName Salary
TotCredits
Advisor
StudID
InstID
1. The Relational Model Demo Exercises 28
Exercises
Department
DeptName Building Budget
Finance Painter 120000
Music Packard 80000
Physics Watson 70000