retagged by
3,564 views
26 votes
26 votes
Suppose we have a database consisting of the following three relations:
$$\begin{array}{|c|c|} \hline \text {FREQUENTS} & \text {(CUSTOMER, HOTEL)} \\\hline \text {SERVES} &  \text{(HOTEL, SNACKS)}\\\hline \text{LIKES} & \text{(CUSTOMER, SNACKS)}\\\hline \end{array}$$
The first indicates the hotels each customer visits, the second tells which snacks each hotel serves and last indicates which snacks are liked by each customer. Express the following query in relational algebra:

Print the hotels the serve the snack that customer Rama likes.
retagged by

3 Answers

Best answer
42 votes
42 votes
OPTIMIZED ANSWER

$\Pi_{hotel} \Big( ( \sigma _{customer = ``Rama"}{(LIKES)} )  \bowtie{SERVES} \Big)$
edited by
13 votes
13 votes

πHotelcustomer = "RAMA"(LIKES (Natural Join)Serves))

0 votes
0 votes
$\Pi_{Hotel} (\;Serves\;\bowtie\;(\sigma_{Customer=Rama}\; Likes)\;)$

Related questions

6 votes
6 votes
1 answer
1
Kathleen asked Sep 13, 2014
984 views
How is redundancy reduced in the following models?HierarchicalNetworkRelational
7 votes
7 votes
2 answers
4
go_editor asked Apr 24, 2016
3,282 views
Let $S$ be the set of all integers and let $n 1$ be a fixed integer. Define for $a,b \in S, a R b$ iff $a-b$ is a multiple of $n$. Show that $R$ is an equivalence relat...