Query Languages Tutorial One
Query Languages Tutorial One
Tutorial Session 4
EXERCISE 11
Using the following tables, evaluate the relational algebra operations listed
below, i.e. show the resulting tables for each operation
TABLE A TABLE B
Order Company City Order Company City
Number Number
A1002 Rentokil London E0102 Halifax plc Halifax
A3333 Eurotunnel Paris D2489 Hanson London
B0987 Kwikfit Glasgow B0987 Kwikfit Glasgow
C7521 BT Edinburgh
E0102 Halifax plc Halifax
(a) A UNION B
(b) A - B
(c) B – A
(d) A INTERSECT B
(e) (A UNION B) [city]
(f) A[city] UNION B[city]
(g) A[company,city] DIFFERENCE B[city]
EXERCISE 2
Using Table A from exercise 1 above, and the following Table C, answer the
following two questions:
TABLE C
Supplier Supplier Name
Number
S900 Ricoh
S804 HP
S805 Canon
1
Exercise 1 can be found in Ritchie C, Relational Database Principles, Continuum, 1998, p39
EXERCISE 3
Use the following tables for this exercise:
ProducedBy Stars
Title Name Title Name
Shrek Jeffery Katzenberg Shrek Mike Myers
Austin Powers Mike Myers Austin Powers Mike Myers
Shrek Eddie Murphy
Austin Powers Liz Hurley
Examine the following result tables and state, for each of (a) to (f), which
relational algebra operation has been performed, and which relation(s) are
involved:
(a) (e)
Name Title Year Name
Mike Myers Shrek 2000 Mike Myers
Liz Hurley
Eddie Murphy Shrek 2000 Jeffery
Jeffery Katzenberg Katzenberg
Austin 1997 Mike Myers
Powers
(b) Austin 1997 Jeffery
Name Powers Katzenberg
Liz Hurley
Eddie Murphy
(f)
Title Year Name
(c) Shrek 2000 Mike Myers
Name
Mike Myers Shrek 2000 Eddie
Murphy
Austin 1997 Mike Myers
(d) Powers
Title Name Austin 1997 Liz Hurley
Shrek Mike Myers Powers
Shrek Eddie Murphy