ago
41 views
0 0 votes

Consider :$$\begin{aligned}
\begin{gathered}
\mathrm{Customer} \\[-2pt]
\begin{array}{|c|c|}
\hline
\mathrm{cid} & \mathrm{name} \\
\hline
1 & \mathrm{Joe} \\
2 & \mathrm{Betty} \\
3 & \mathrm{Sally} \\
4 & \mathrm{Harry} \\
\hline
\end{array}
\end{gathered}
&\hspace{3cm}
\begin{gathered}
\mathrm{Reserves} \\[-2pt]
\begin{array}{|c|c|c|}
\hline
\mathrm{cid} & \mathrm{title} & \mathrm{date} \\
\hline
1 & \mathrm{Sleeper} & 01/01/01 \\
1 & \mathrm{Bananas} & 01/01/01 \\
2 & \mathrm{Sleeper} & 01/01/01 \\
2 & \mathrm{Annie\ Hall} & 02/01/01 \\
2 & \mathrm{Sleeper} & 02/01/01 \\
2 & \mathrm{Interiors} & 02/01/01 \\
4 & \mathrm{Sleeper} & 03/01/01 \\
5 & \mathrm{Zelig} & 03/01/01 \\
\hline
\end{array}
\end{gathered}
\end{aligned}$$

What is the cardinality of $\mathrm{Customer}\ \mathbin{⟗}_{\mathrm{Customer}.\mathrm{cid}=\mathrm{Reserves}.\mathrm{cid}}\ \mathrm{Reserves}?$

  1. $7$
     
  2. $8$
     
  3. $9$
     
  4. $12$

1 Answer

0 0 votes

First count the matching tuples.

For $\mathrm{cid}=1$, Joe matches two reservation tuples $:2$ tuples.

For $\mathrm{cid}=2$, Betty matches four reservation tuples $:4$ tuples.

For $\mathrm{cid}=4$, Harry matches one reservation tuple $:1$ tuple.

Therefore, the inner-join portion contains $2+4+1=7$ tuples.

Now consider dangling $\mathrm{Customer}$ tuples. 

Sally, with $\mathrm{cid}=3$, has no reservation. 

The full outer join preserves her $:+1$.

Now consider dangling $\mathrm{Reserves}$ tuples. 

The reservation with $\mathrm{cid}=5$ has no corresponding customer. 

The full outer join preserves it as well $:+1$

$\therefore 7+1+1=9$.

Hence, Answer : C

 

Note : Full Outer Join = matched tuples + dangling left tuples + dangling right tuples.

ago
Answer:
Position:
Show:

Related questions

0 0 votes
1 1 answer
51
51 views
GO Classes asked 4 days ago
51 views
Consider $\mathrm{A}(\mathrm{c1},\mathrm{c2},\mathrm{c3})$ and $\mathrm{B}(\mathrm{c1},\mathrm{c2},\mathrm{c3})$, where $\mathrm{c1}$ is the primary key of each relation....
0 0 votes
1 1 answer
46
46 views
GO Classes asked 4 days ago
46 views
Consider $\mathrm{Homes}(\mathrm{home\_id},\mathrm{city},\ldots)$ and $\mathrm{Transactions}(\mathrm{home\_id},\mathrm{sale\_price},\ldots)$.We want every home in Berkele...
0 0 votes
3 3 answers
73
73 views
GO Classes asked 4 days ago
73 views
Consider $ \mathrm{MEMBER}(\mathrm{personName}, \mathrm{groupName}) $ and $ \mathrm{PICTURE}(\mathrm{groupName}, \mathrm{picture}) $.Every person belongs to at least one ...
1 1 vote
1 1 answer
44
44 views
GO Classes asked 4 days ago
44 views
Let $\mathrm{R}(\mathrm{A},\mathrm{B})$ and $\mathrm{S}(\mathrm{A},\mathrm{B})$ be relations under set semantics.Which expression is not always equivalent to the others?$...