Consider the following three relations:
Car (model, year, serial, color)
Make (maker, model)
Own (owner, serial)
A tuple in Car represents a specific car of a given model, made in a given year, with a serial number and a color. A tuple in Make specifies that a maker company makes cars of a certain model. A tuple in Own specifies that an owner owns the car with a given serial number. Keys are underlined; (owner, serial) together form key for Own. ($\bowtie$ denotes natural join)
$ \pi_{\text{owner}} (\text{Own} \bowtie (\sigma_{\text{color}=\text{"red"}} (\text{Car} \bowtie (\sigma_{\text{maker}=\text{“ABC”}} \text{Make})))) $
This solution breaks down the relational algebra query to identify specific car owners based on car attributes.
The query is:
$ \pi_{\text{owner}} (\text{Own} \bowtie (\sigma_{\text{color}=\text{"red"}} (\text{Car} \bowtie (\sigma_{\text{maker}=\text{“ABC”}} \text{Make})))) $
We will analyze this expression step-by-step, starting from the innermost operations.
The operation $ \sigma_{\text{maker}=\text{“ABC”}} \text{Make} $ filters the $Make$ relation to find all models produced by the maker "ABC".
Then, the natural join $ \text{Car} \bowtie (\dots) $ combines this result with the $Car$ relation based on the $model$ attribute. This yields tuples representing cars that are made by "ABC".
The selection $ \sigma_{\text{color}=\text{"red"}} (\dots) $ is applied to the result from Step 1. This filters the set of cars made by "ABC" to include only those whose $color$ is "red".
The result at this stage represents red cars made by "ABC".
The natural join $ \text{Own} \bowtie (\dots) $ connects the red cars made by "ABC" (from Step 2) with the $Own$ relation using the $serial$ attribute. This creates tuples linking owners to specific red cars made by "ABC".
Finally, the projection $ \pi_{\text{owner}} (\dots) $ selects only the $owner$ attribute from the joined result. This gives the final list of unique owners who own at least one red car made by "ABC".
The query effectively finds all owners associated with cars that satisfy both conditions: being red and being made by "ABC".
Consider the given relations $X$, $Y$ and $Z$. The relation $X$ has three columns $P$, $Q$ and $R$. The relation $Y$ has three columns $P$, $Q$ and $S$. The relation $Z$ has two columns $P$ and $T$.
Table X
| P | Q | R |
|---|---|---|
| P1 | Q1 | R1 |
| P2 | Q2 | R2 |
| P3 | Q3 | R2 |
Table Y
| P | Q | S |
|---|---|---|
| P1 | Q1 | 2 |
| P1 | Q2 | 5 |
| P2 | Q1 | 6 |
| P3 | Q3 | 1 |
Table Z
| P | T |
|---|---|
| P1 | T1 |
| P3 | T2 |
| P4 | T3 |
| P4 | NULL |
Consider the relational algebra expression $$ \Pi_{P, R, S} \left[ \left( \sigma_{(Q = Q3 \lor R = R2)} [X \bowtie Y] \right) \bowtie \left( \sigma_{(S > 1)} [Y \bowtie Z] \right) \right] $$ where $\bowtie$ denotes natural join operation.
Which of the following options is the correct output for the given expression?
Consider a database that includes the following relations:
Defender($name, rating, side, goals$)
Forward($name, rating, assists, goals$)
Team($name, club, price$)
Which ONE of the following relational algebra expressions checks that every name occurring in Team appears in either Defender or Forward, where $\phi$ denotes the empty set?
Consider the following tables, Loan and Borrower of a bank.
| Loan | Borrower | |||
|---|---|---|---|---|
| loan_num | branch_name | amount | customer_name | loan_num |
| L11 | Banjara Hills | 90000 | Anand | L11 |
| L14 | Kondapur | 50000 | Karteek | L11 |
| L15 | SR Nagar | 40000 | Ankita | L15 |
| L22 | SR Nagar | 25000 | Gopal | L19 |
| L23 | Balanagar | 80000 | Karteek | L22 |
| L25 | Kondapur | 70000 | Karteek | L23 |
| L19 | SR Nagar | 65000 | Sunil | L23 |
| Sunil | L25 | |||
Query: $\pi_{\text{branch\_name}, \text{customer\_name}}(\mathbf{Loan} \bowtie \mathbf{Borrower}) \div \pi_{\text{branch\_name}}(\mathbf{Loan})$
where $\bowtie$ denotes natural join.
The number of tuples returned by the above relational algebra query is _______
(Answer in integer)
Consider the following three relations
Employee (eid, eName), Comp(cid, cName), Own(eid, cid). Which of the following relational algebra expression return the set of eids who own all brands: