Awesome q2a theme
0 votes
2 views

Consider the relation account (customer, balance) where the customer is a primary key and there are no null values. We would like to rank customers according to decreasing balance. The customer with the largest balance gets rank 1. Ties are not broke but ranks are skipped: if exactly two customers have the largest balance they each get rank 1 and rank 2 is not assigned.

 

$\large {Query\space 1:}$ 

$\text{select A.customer, count(B.customer)}$

$\text{from account A, account B}$

$\text{where A.balance <=B.balance}$

$\text{group by A.customer}$

     

$\large {Query\space 2:}$

$\text{select A.customer, 1+count(B.customer)}$

$\text{from account A, account B}$

$\text{where A.balance < B.balance}$

$\text{group by A.customer}$

 

Consider these statements about Query 1 and Query 2.

  1.  Query 1 will produce the same row set as Query 2 for some but not all databases. 
  2.  Both Query 1 and Query 2 are a correct implementation of the specification 
  3.  Query1 is a correct implementation of the specification but Query 2 is not 
  4.  Neither Query 1 nor Query 2 is a correct implementation of the specification 
  5.  Assigning rank with a pure relational query takes less time than scanning in decreasing balance order assigning ranks using ODBC. 

Which two of the above statements are correct?

  1. 2 and 5
  2. 1 and 3
  3. 1 and 4
  4. 3 and 5
in Databases by (3.6k points) | 2 views

Please log in or register to answer this question.

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
Top Users Jul 2020
  1. Shaik Masthan

    39 Points

  2. hiteshpujari

    9 Points

  3. Venkatesh Akhouri

    6 Points

  4. Meghana518

    6 Points

  5. bittujash

    6 Points

  6. Pawan_k

    6 Points

  7. rits78671

    6 Points

  8. srestha

    6 Points

  9. RavGopal

    4 Points

  10. Sumaiyas

    4 Points

7,543 questions
1,783 answers
10,867 comments
90,482 users