-
Relational-algebra expression. Help!
Consider the following relations from a Restaurant database.
(Primary key is given in bold and underlined)
Restaurant(Rid, Location)
Person(Pid, Pname, Address, Tel_no)
Customer(Pid, Date_of_joining)
Owns(Pid, Rid)
EatsAt(Pid, Rid, Date)
Likes(Pid, DishName, Rid)
Dish(DishName, Rid, Price)
Write the relational-algebra expression for the following queries.
(a) Give the list of Pids of customers who like “Fish curry” and “Chicken Curry”.
(b) Give the list of Pids of customers who eat at a restaurant that has at least one
‘un-liked’ dish. If a dish is not liked by any customer, then it is an ‘un-liked’
dish.
(c) Give the list of Pids of owners of restaurants who do not eat anywhere other
than the restaurant(s) that they own.
(d) Construct TWO relational algebra expressions for the following SQL statement.
Show that one of the relational algebra expressions is optimum.
Select L.Rid, L.DishName, L.Pid, C. Date-of-joining
From Restaurant R, Customer C, EatsAt E, Likes L, Dish D
Where R.Rid = E.Rid
And E.Pid = C.Pid
And C.Pid = L.Pid
And L.Dishname=D.Dishname
And Dishname =”Honey-Snow”
And Date = 14-02-2008
And Price=”$15”
And Location = “East coast”
Answers needed
-
I would use more than two queries to gather this data. Use loops and conditionals in your code to get to the answers.
Hope this helps,
Larry Darrah
MS AE
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|