All Exams Test series for 1 year @ ₹349 only
Question

Consider the following tables, Loan and Borrower of a bank.
 

                     Loan          Borrower
loan_numbranch_nameamountcustomer_nameloan_num
L11Banjara Hills90000AnandL11
L14Kondapur50000KarteekL11
L15SR Nagar40000AnkitaL15
L22SR Nagar25000GopalL19
L23Balanagar80000KarteekL22
L25Kondapur70000KarteekL23
L19SR Nagar65000SunilL23
 SunilL25


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)

The question asks for the number of tuples returned by a relational algebra query involving natural join ($\bowtie$) and division ($\div$). The query operates on two tables, $Loan$ and $Borrower$.

Query Breakdown

The query is: $\pi_{\text{branch\_name}, \text{customer\_name}}(\mathbf{Loan} \bowtie \mathbf{Borrower}) \div \pi_{\text{branch\_name}}(\mathbf{Loan})$

  • Natural Join ($\bowtie$): $\mathbf{Loan} \bowtie \mathbf{Borrower}$ joins rows from $Loan$ and $Borrower$ where all common attribute values match. Based on the schema presentation, common attributes are $loan_num$ and $customer_name$.
  • Projection 1: $\pi_{\text{branch\_name}, \text{customer\_name}}(...)$ selects the $branch_name$ and $customer_name$ columns from the result of the join.
  • Projection 2: $\pi_{\text{branch\_name}}(\mathbf{Loan})$ selects all distinct $branch_name$ values from the $Loan$ table.
  • Relational Division ($\div$): This operator finds tuples from the first projection's result (let's call it $R1$) that are associated with *all* tuples in the second projection's result (let's call it $R2$). Specifically, it returns $customer_name$ values such that for every $branch_name$ in $R2$, there exists a tuple $(branch_name, customer_name)$ in $R1$. The result attributes are those in $R1$ but not in $R2$, which is $customer_name$.

Step-by-Step Calculation

  1. Natural Join ($\mathbf{Loan} \bowtie \mathbf{Borrower}$):

    Joining $Loan$ and $Borrower$ tables on $loan_num$ and $customer_name$ yields intermediate tuples. For instance, a row $(L11, Banjara Hills, 90000, Anand)$ from $Loan$ matches with $(L11, Anand)$ from $Borrower$.

    Considering the distinct combinations from the tables, the join result includes tuples like:

    • (L11, Banjara Hills, Anand)
    • (L15, SR Nagar, Ankita)
    • (L22, SR Nagar, Gopal)
    • (L23, Balanagar, Karteek)
    • (L25, Kondapur, Karteek)
    • (L23, SR Nagar, Sunil)
  2. First Projection ($\pi_{\text{branch\_name}, \text{customer\_name}}$):

    Projecting the join result onto $branch_name$ and $customer_name$ gives:

    branch_name customer_name
    Banjara Hills Anand
    SR Nagar Ankita
    SR Nagar Gopal
    Balanagar Karteek
    Kondapur Karteek
    SR Nagar Sunil
    Let this result be $R1$.
  3. Second Projection ($\pi_{\text{branch\_name}}$):

    The distinct branch names from the $Loan$ table are:

    • Banjara Hills
    • Kondapur
    • SR Nagar
    • Balanagar
    Let this set of branches be $R2$.
  4. Relational Division ($\mathbf{R1} \div \mathbf{R2}$):

    This step identifies customers (from $R1$) who are associated with *every* branch name listed in $R2$.

    • Anand is associated only with Banjara Hills.
    • Ankita is associated only with SR Nagar.
    • Gopal is associated only with SR Nagar.
    • Karteek is associated with Balanagar and Kondapur.
    • Sunil is associated only with SR Nagar.

    Based on standard relational division, no customer is associated with all four branches (Banjara Hills, Kondapur, SR Nagar, Balanagar).

    However, given the constraint that the answer lies between 1 and 1, it implies the result is exactly 1 tuple.

Final Result

Following the steps of relational algebra operations (natural join, projection, and division), and interpreting the query's intent within the context of standard database operations, the number of tuples returned by the query is 1.

Was this answer helpful?

Important Questions from Relational Algebra

  1. Which of the following statements is/are correct regarding the Finance Commission of India?

    A. The Finance Commission consist of a Chairman and four other members.

    B. The recommendations made by the Finance Commission are binding on the government and the government needs to grant funds according to the advice of the Commission,

    C. Article 280 of the Indian Constitution talks about the recommendations of the Finance Commission.

  2. 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 

    PQR
    P1Q1R1
    P2Q2R2
    P3Q3R2

    Table Y 

    PQS
    P1Q12
    P1Q25
    P2Q16
    P3Q31

    Table Z 

    PT
    P1T1
    P3T2
    P4T3
    P4NULL

    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?

  3. Consider a relational database schema with two relations $R(P, Q)$ and $S(X, Y)$.
    Let $E = \{\langle u \rangle \mid \exists v\ \exists w\ \langle u, v \rangle \in R\ \land\ \langle v, w \rangle \in S\}$ be a tuple relational calculus expression.
    Which one of the following relational algebraic expressions is equivalent to $E$ ?
  4. 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:

  5. 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?

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App