Answer to Question #157802 in Databases | SQL | Oracle | MS Access for dixon

Question #157802

Pizza(pizza)

Customers (cname,area)

Restaurants (rname,area)

Contains (pizza,ingredient)

Sells(rname,pizza,price)

Likes(cname,pizza)


Primary keys are bolded

Foreign keys are:

• Contains.pizza is a foreign key that refers to Pizzas.pizza.

• Sells.rname is a foreign key that refers to Restaurants.rname.

• Sells.pizza is a foreign key that refers to Pizzas.pizza.

• Likes.cname is a foreign key that refers to Customers.cname.

• Likes.pizza is a foreign key that refers to Pizzas.pizza.


Answer in Relational Algebra Format


Find all customer-pizza pairs (C, P) where the pizza P is sold by some restaurant

that is located in the same area as that of the customer C. Include customers

whose associated set of pizzas is empty.


1
Expert's answer
2021-01-23T10:20:01-0500

a) πpizza (σpizza (cname='Alice' and cname<>'Bob') Likes )

b) πcanme,rname (σcname,rname (Customers ⋈ customers.area = restaurants.area Restaurants ⋈ restaurants.rname = sells.rname Sells ⋈ sells.pizza = likes.pizza Likes )

c) πLikes.cname,Pizza.pizza ( σ Likes.cname,Pizza.pizza(Likes.pizza<>Pizza.pizza) (Pizza x Likes) )

d) πL1.cname,L2.cname ( σL1.cname,L2.cname(L1.cname<>L2.cname and L1.pizza<>L2.pizza) (Likes L1 x Likes L2) )

e) πL1.cname,L2.cname ( σL1.cname,L2.cname(L1.cname<>L2.cname and L1.pizza=L2.pizza) (Likes L1 x Likes L2) )

f)  πprice ( rname γ MAX(price) (Sells) ) -- γ is grouping symbol

g)  πcname,pizza (σcname,pizza (Likes ⟖ Likes.cname = Customers.cname Customers ⋈ Customers.area = Restaurants.area Restaurants ⋈ restaurants.rname = sells.rname Sells) )

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS