IST601 20242025 - Relational Algebra-Calculus
IST601 20242025 - Relational Algebra-Calculus
Relational Algebra
(Chapter 5)
Denis L. Nkweteyim
●
Example
●
List all staff with a salary
greater than £10000
●
σsalary > 10000(Staff)
●
Example
●
Produce a list of salaries for all
staff, showing only the staffNo,
fName, IName, and salary details
●
ΠstaffNo, fName, IName, salary(Staff)
●
Example
●
List the names and comments of all clients who have viewed a
property for rent
●
Can start with Cartesian product, then select from rows
●
(ΠclientNo, fName, IName(Client)) x (ΠclientNo, propertyNo, comment(Viewing))
●
Results on following slide
●
Example
●
List the names and comments of all clients who have
viewed a property for rent
●
(ΠclientNo, fName, Iname(Client)) Client.clientNo = Viewing.clientNo
(ΠclientNo, propertyNo, comment(Viewing))
●
Or,
●
Results = TempClient Client.clientNo = Viewing.clientNo TempViewing
●
Example
●
List the names and comments of all clients who have
viewed a property for rent
●
(ΠclientNo, fName, Iname(Client)) (ΠclientNo, propertyNo, comment(Viewing))
●
Or,
●
Results ← TempClient TempViewing
●
Defines a relation that contains the tuples of R that
participate in the join of R with S satisfying the predicate F
●
Can be rewritten using Projection and Join operations
●
A is the set of all attributes for R
●
Example
●
List complete details of all staff who work at
the branch in Glasgow
●
(b) Find the minimum, maximum, and
average staff salary