0% found this document useful (0 votes)
9 views6 pages

Assignment - Relational Algebra

The document provides instructions and examples for using relational algebra to query multiple tables and return results. It includes sample tables for clients, properties, owners, and staff and asks the student to write relational algebra expressions to retrieve specific fields based on queries. The student is also asked to show the output tables that would result from several relational algebra expressions operating on the sample tables.

Uploaded by

amigostrio1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views6 pages

Assignment - Relational Algebra

The document provides instructions and examples for using relational algebra to query multiple tables and return results. It includes sample tables for clients, properties, owners, and staff and asks the student to write relational algebra expressions to retrieve specific fields based on queries. The student is also asked to show the output tables that would result from several relational algebra expressions operating on the sample tables.

Uploaded by

amigostrio1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Assignment—Relational Algebra

Total Point: 10

Student’s Name:

Task A:

[(Expression 0.75 + Output relation 0.5) * 4 = 5]

Using the tables in page 2, construct relational algebra expressions to answer the
following queries and represent the answer as a relation (output table):

1. Names and telephone numbers of the clients registered at Branch B003.

Solution:

RA expression: Π fName, lName, telNo (σ branchNo = 'B003' (Client X


Registration))

Output Table:

fName lName telNo


Aline Stewart 0141-848-1825
Mike Ritchie 01475-392178

2. Which staff members were born after 1955? Include only staff numbers
and names.

Solution:

RA expression: Π staffNo, fName, lName (σ DOB > '1955-12-31' (Staff))

Output Table:
staffNo fName lName
SA9 Mary Howe
SG14 David Ford
SG37 Ann Beech
SL41 Julie Lee

1 | Page
3. List the flats with rent greater than $500.

Solution:

RA expression: Π street, city, rent (σ type = 'Flat' AND rent > 500
(PropertyForRent))

Output Table:

street city rent

4. Telephone numbers of the owners who have property at London.

Solution:

RA expression: Π telNo (σ city = 'London' (PrivateOwner X PropertyForRent))

Output Table:

telNo
0141-357-7419

2 | Page
Task B:

[1*5 = 5]

Using the tables in page 2, show the relation (table including column headings)
created by the following relational algebra expressions as a two-dimensional table:

1. Π fName,LName, rooms, rent(σtype =preftype (Client X PropertyForRent) )

Solution:

Table:
fName lName Rooms rent
Aline Stewart 4 $450.00
Aline Stewart 3 $375.00
Aline Stewart 3 $350.00
Aline Stewart 4 $400.00
Mary Tregear 4 $450.00
Mary Tregear 3 $375.00
Mary Tregear 3 $350.00
Mary Tregear 4 $400.00
Mike Ritchie 6 $650.00
Mike Ritchie 5 $600.00
John Kay 4 $450.00
John Kay 3 $375.00
John Kay 3 $350.00
John Kay 4 $400.00

2. Π LName,position (σcity = “London” ( PropertyForRent Staff ) )

Solution:

Table:
lName Position
Lee Assistant

3 | Page
3. Π staffNo ( Registeration ) Π staffNo (PropertyForRent)

Solution:

Table:
staffNo(Registration) staffNo(PropertyForRent)
SG37 SA9
SA9 SG154
SG37 SG37
SL41 SL41

4. Π branchNo (Branch) - Π branchNo (Staff )

Solution:

Table:
branchNo
B002
B004

5. ΠfName,LName (σ propertyNo IS NULL (Staff PropertyForRent))

Solution:

Table:
fName lName
Susan Brand
John White

4 | Page
Branch Viewing
branchNo street city postcode
B002 56 Clover Dr London NW10 6EU
B003 163 Main St Glasgow G11 9QX
B004 32 Manse Rd Bristol BS99 1NZ
B005 22 Deer Rd London SWI 4EH
B007 16 Argyll St Aberdeen AB2 3SU

clientNo propertyNo viewDate comment


Client
CR76 PG4 4/20/2001 too remote
CR56 PG36 4/28/2001
CR62 PA14 5/14/2001 no dining room
CR56 PA14 5/24/2001 too small
CR56 PG4 5/26/2001
clientNo fName lName telNo prefType maxRent
CR56 Aline Stewart 0141-848-1825 Flat $350.00
CR62 Mary Tregear 01224-196720 Flat $600.00
CR74 Mike Ritchie 01475-392178 House $750.00
CR76 John Kay 0207-774-5632 Flat $425.00
PrivateOwner
ownerNo fName lName Address telNo
CO40 Tina Murphy 63 Wells St, Glasgow G42 0141-943-1728
CO46 Joe Keogh 2 FergusDr, Aberdeen AB2 7SX 01224-861212
CO87 Carol Farrel 6 Achray St, Glasgow G32 9DX 0141-357-7419
CO93 Tony Shaw 12 Park Pl, Glasgow G4 0QR 0141-225-7025
PropertyForRent
Propertyno street city Postcode type rooms rent ownerNo staffNo branchNo
PA14 16 Holhead Aberdeen AB7 5SU House 6 $650.00 CO46 SA9 B007
PG16 5 Novar Dr Glasgow G12 9AX Flat 4 $450.00 CO93 SG14 B003
PG21 18 Dale Rd Glasgow G12 House 5 $600.00 CO87 SG37 B003
PG36 2 Manor Rd Glasgow G32 4QX Flat 3 $375.00 CO93 SG37 B003
PG4 6 Lawrence St Glasgow G11 9QX Flat 3 $350.00 CO40 B003
PL94 6 Argyll St London NW2 Flat 4 $400.00 CO87 SL41 B005
Registration
clientNo branchNo staffNo dateJoined
CR56 B003 SG37 4/11/2000
CR62 B007 SA9 3/7/2000
CR74 B003 SG37 11/16/1999
CR76 B005 SL41 1/2/2001
Staff
staffNo fName lname position sex DOB salary branchNo
SA9 Mary Howe Assistant F 2/19/1970 9,000.00 B007
SG14 David Ford Supervisor M 3/24/1958 18,000.00 B003
SG37 Ann Beech Assistant F 11/10/1960 12,000.00 B003
SG5 Susan Brand Manager F 6/3/1940 24,000.00 B003

5 | Page
SL21 John White Manager M 10/1/1945 30,000.00 B005
SL41 Julie Lee Assistant F 6/13/1965 9,000.00 B005

6 | Page

You might also like