Вы находитесь на странице: 1из 9

GATEBOOK-2019-DBMS1-6 - GATE Overflow https://gateoverflow.in/272680/gatebook-2019-...

The Gateway to Computer Science Excellence

For all GATE CSE Questions


 (https://www.facebook.com/GATEOverflow)  (https://twitter.com/gateoverflow) 
(mailto:gatecse@gateoverflow.in)  (https://plus.google.com/+GateoverflowIn)

Use the google search bar on side panel. It searches through all previous GATE/other questions.
For hardcopy of previous year questions please see here (https://gateoverflow.in/blog/4490/go-
hardcopy-2019)

GATEBOOK-2019-DBMS1-6 (../272680/gatebook-
2019-dbms1-6)

 +3
 votes

122 views
Consider the following database schema:

Frequents(kid, store)
Sells(store, candy)
Likes(kid, candy)

Table Frequents indicates what candy stores a kid likes to visit.


Table Sells shows which candy each store sells. Table Likes tells which candy a
kid likes.

Consider the following query:

(Select kid from likes) EXCEPT


(select kid from likes where candy NOT in (select candy from sells wh
ere store = ‘Starbucks’);

The query prints

A. the kids whose liked candies are not all sold by the 'Starbucks'.
B. the kids whose liked candies are only sold by the 'Starbucks'.
C. the kids whose liked candies are all sold by the store 'Starbucks'.
D. the kids whose liked candies are sold by stores other than 'Starbucks'

gb2019-dbms1 (../tag/gb2019-dbms1) sql (../tag/sql)

(../user/GATEBOOK)

1 of 9 12/02/19, 10:34 am
GATEBOOK-2019-DBMS1-6 - GATE Overflow https://gateoverflow.in/272680/gatebook-2019-...

asked (../272680/gatebook-2019-dbms1-6) Nov 30, 2018 in Databases (../databases) by GATEBOOK (../user


/GATEBOOK) Boss (15.3k points) |  122 views

 Answer  Comment

1 Answer

 +1
 vote select candy from sells where store = ‘Starbucks’

Select all the candies which sold by  'Starbucks.'



select kid from likes where candy NOT in
Best answer

Select those kids who do not like candies from 'Starbucks' or those kids who
do not buy any candies from 'Starbucks'.

(Select kid from likes) EXCEPT

Select those kids whose all liked candies are sold by the 'Starbucks'.

Option C.

Note -

. Except and set difference both are same.

.  B is not the answer because it says only sold by 'Starbucks'. But there is
possibility that some candies which are sold by Satrbucks can also be sold
by different store.

(../user/Shubhgupta)
answered (../272680/gatebook-2019-dbms1-6?show=272958#a272958) Dec 1, 2018 by Shubhgupta
(../user/Shubhgupta) ✔ Loyal (8.4k points)
selected Dec 14, 2018 by Shaik Masthan (../user/Shaik+Masthan)

 Comment

 but this query will not select those kids whose liked candy is from another
0
 store also. So B is wrong because it says only sold by 'Starbucks.'

(../user/Shubhgupta)
commented (../272680/gatebook-2019-dbms1-6?show=278290#c278290) Dec 14, 2018 by Shubhgupta (../user
/Shubhgupta) ✔ Loyal
 Reply


0 Mis-understood the options....

2 of 9 12/02/19, 10:34 am
GATEBOOK-2019-DBMS1-6 - GATE Overflow https://gateoverflow.in/272680/gatebook-2019-...

(../user/Shaik+Masthan)
commented (../272680/gatebook-2019-dbms1-6?show=278300#c278300) Dec 14, 2018 by Shaik Masthan (../user
/Shaik+Masthan) ✔ Veteran
 Reply

 @Shaik Masthan (https://gateoverflow.in/user/Shaik+Masthan)


0

except returns only

isnot it?

see this https://gateoverflow.in/43857/isro-2013-24 (https://gateoverflow.in


/43857/isro-2013-24)

(../user/srestha)
commented (../272680/gatebook-2019-dbms1-6?show=290062#c290062) Jan 6 by srestha (../user/srestha) ✔
Veteran
 Reply

 yes mam, but i am not getting, what is your doubt regarding this question ?
0

(../user/Shaik+Masthan)
commented (../272680/gatebook-2019-dbms1-6?show=290080#c290080) Jan 6 by Shaik Masthan (../user
/Shaik+Masthan) ✔ Veteran
 Reply

 @Shaik Masthan (https://gateoverflow.in/user/Shaik+Masthan)


0

answer will be B) 

In inner query it returns "kid likes candy which sold all other stores other
than starbucks"

Now, outer query returns, "kid likes candy which sold by only starbucks"

(../user/srestha)
commented (../272680/gatebook-2019-dbms1-6?show=290090#c290090) Jan 6 by srestha (../user/srestha) ✔
Veteran
 Reply

 @srestha (https://gateoverflow.in/user/srestha), above query which you


0
 mentioned is different in which you are creating two result set one with all
pid's and one with pid's which are excluded from sachin so its obvious that
final query will return only sold by sachin. 

but run this query on below schema.

sells- 

STARBUCKS A
CCD B
MCD A

likes-

1 A
2 A
3 B

3 of 9 12/02/19, 10:34 am
GATEBOOK-2019-DBMS1-6 - GATE Overflow https://gateoverflow.in/272680/gatebook-2019-...

(../user/Shubhgupta)
commented (../272680/gatebook-2019-dbms1-6?show=290125#c290125) Jan 6 by Shubhgupta (../user
/Shubhgupta) ✔ Loyal
 Reply

← Prev. Qn. in Sub. (../272679/gatebook-2019-dbms1-7)

Next Qn. in Sub. → (../272681/gatebook-2019-dbms1-5)

← Prev. (../272679/gatebook-2019-dbms1-7) Next → (../272681/gatebook-2019-dbms1-5)

Answer: C

Related questions
GATEBOOK-2019-DBMS1-4  +1
The table Arc(x,y) currently has the following tuples (note  vote

there are duplicates):


(1, 2), (1, 2), (2, 3), (3, 4), (3, 4), (4, 1), (4, 1), (4, 1), (4, 2). 1
answer
Compute the result of the query: SELECT a1.x, a2.y,
1
COUNT(*) FROM Arc a1, Arc a2 WHERE a1.y = a2.x GROUP
BY a1 ... following tuples is in the result? (1, 3, 2) (2, 4, 6)
(3, 1, 4) (3, 1, 6) I and III I and II I and IV II and III (../272682
/gatebook-2019-dbms1-4)

asked Nov 30, 2018 in Databases (../databases) by GATEBOOK


(../user/GATEBOOK)
(../user/GATEBOOK) Boss (15.3k points) |  77 views

gb2019-dbms1 (../tag/gb2019-dbms1) sql (../tag/sql)

GATEBOOK-2019-DBMS1-1  +1
Given two relations R1 and R2 , where R1 contains N1  vote

tuples, R2 contains N2 tuples, and N2 > N1 > 0, give


the minimum possible sizes (in tuples) for the resulting 1
answer
relation produced by each of the following relational
2
algebra expressions. In each case, state any assumptions
... (1) − N2 ; (2) − 0; (3) − 0; (4) − N1 × N2 ; (5) − N1
(../272685/gatebook-2019-dbms1-1)

asked Nov 30, 2018 in Databases (../databases) by GATEBOOK


(../user/GATEBOOK)
(../user/GATEBOOK) Boss (15.3k points) |  220 views

gb2019-dbms1 (../tag/gb2019-dbms1)

4 of 9 12/02/19, 10:34 am
GATEBOOK-2019-DBMS1-6 - GATE Overflow https://gateoverflow.in/272680/gatebook-2019-...

relational-algebra (../tag/relational-algebra)

GATEBOOK-2019-DBMS1-2  0
Suppliers(sid: integer, sname: string, address: string)  votes

Parts(pid: integer, pname: string, color: string) Catalog(sid:


integer, pid: integer, cost: real) Suppose we want to find 1
answer
names of those suppliers who supply all the parts.
3
Consider the following ... .sid) Which of the following query
is the correct implementation of above requirement ? Only
Q1 Only Q2 Both Q1 and Q2 None (../272684/gatebook-
2019-dbms1-2)

asked Nov 30, 2018 in Databases (../databases) by GATEBOOK


(../user/GATEBOOK)
(../user/GATEBOOK) Boss (15.3k points) |  80 views

gb2019-dbms1 (../tag/gb2019-dbms1)

GATEBOOK-2019-DBMS1-3  +1
Suppose that two relations R(A, B) and S(A, B) have  vote

exactly the same schema. Consider the following


equalities in relational algebra? R ∩ S = R − (R − S) 1
answer
R ∩ S = S − (S − R)
4
R ∩ S = R NATURAL-JOIN S R ∩ S = R × S
Which of the equalities hold in relational algebra? I only I
and II only I, II and III I, II, III and IV (../272683/gatebook-
2019-dbms1-3)

asked Nov 30, 2018 in Databases (../databases) by GATEBOOK


(../user/GATEBOOK)
(../user/GATEBOOK) Boss (15.3k points) |  138 views

gb2019-dbms1 (../tag/gb2019-dbms1)

GATEBOOK-2019-DBMS1-5  +1
The relation R(a, b) may have duplicate tuples. Which of  vote

the following queries has a result that is guaranteed not to


have duplicates, regardless of what tuples R contains? 1
answer
SELECT a FROM R WHERE a = 1 SELECT MAX(b) FROM R
5
GROUP BY a SELECT a, b FROM R GROUP BY a, b
SELECT a FROM R WHERE a NOT IN (SELECT a FROM R)
III and IV I and II III only I and III (../272681/gatebook-2019-
dbms1-5)

5 of 9 12/02/19, 10:34 am
GATEBOOK-2019-DBMS1-6 - GATE Overflow https://gateoverflow.in/272680/gatebook-2019-...

asked Nov 30, 2018 in Databases (../databases) by GATEBOOK


(../user/GATEBOOK)
(../user/GATEBOOK) Boss (15.3k points) |  79 views

gb2019-dbms1 (../tag/gb2019-dbms1)

GATEBOOK-2019-DBMS1-7  +4
Consider a relation R(A, B), and the following two  votes

sequences of queries. Q1: UPDATE R SET B = 3 WHERE B


= 2; Q2: INSERT INTO R SELECT A, 3 FROM R WHERE B = 1
answer
2; DELETE FROM R WHERE B = 2; Which of the following
6
statements is TRUE? Q1 ... produce the same answer. The
answer to Q1 is always contained in the answer to Q2 The
answer to Q2 is always contained in the answer to Q1.
(../272679/gatebook-2019-dbms1-7)

asked Nov 30, 2018 in Databases (../databases) by GATEBOOK


(../user/GATEBOOK)
(../user/GATEBOOK) Boss (15.3k points) |  96 views

gb2019-dbms1 (../tag/gb2019-dbms1)

GATEBOOK-2019-DBMS1-8  +1
Suppose we have a relation declared by: CREATE TABLE  vote

R(name VARCHAR(50) PRIMARY KEY, salary INT


CHECK(salary \leq 40000) ); Initially, the relation has three 1
answer
records: Name Salary Tom 10000 Joe 20000 Sue 30000 We
7
execute the following sequence of modifications. Some of
them may be ... , the sum of the salaries over all the tuples
in R is: 52, 000 62, 000 65, 000 72, 000 (../272678
/gatebook-2019-dbms1-8)

asked Nov 30, 2018 in Databases (../databases) by GATEBOOK


(../user/GATEBOOK)
(../user/GATEBOOK) Boss (15.3k points) |  65 views

gb2019-dbms1 (../tag/gb2019-dbms1)

Custom Search

Search 

6 of 9 12/02/19, 10:34 am
GATEBOOK-2019-DBMS1-6 - GATE Overflow https://gateoverflow.in/272680/gatebook-2019-...

Quick search syntax

Tag Search

Recent Posts

How to minimize silly mistake ? (https://gateoverflow.in/blog/7349/how-to-minimize-silly-mistake)

Coding Interview (https://gateoverflow.in/blog/7342/coding-interview)

Recommended textbooks for GATE (https://gateoverflow.in/blog/7331/recommended-textbooks-


for-gate)

Just for helping future aspirants (https://gateoverflow.in/blog/7328/just-for-helping-future-


aspirants)

Score Calculator for GATE Mechanical 2019 (https://gateoverflow.in/blog/7323/score-calculator-for-


gate-mechanical-2019)

All categories (../)


General Aptitude (../general-aptitude) 1.5k

Engineering Mathematics (../mathematics) 7.1k

Digital Logic (../digital-logic) 2.7k

Programming & DS (../programming-in-c) 4.9k

Algorithms (../algorithms) 4.2k

Theory of Computation (../theory-of-computation) 5.3k

Compiler Design (../compilers) 2.1k

Operating System (../operating-system) 4k

Databases (../databases) 4k

CO & Architecture (../co-and-architecture) 3.5k

Computer Networks (../computer-networks) 4k

Non GATE (../out-of-syllabus-now) 1.4k

Others (../others) 1.5k

7 of 9 12/02/19, 10:34 am
GATEBOOK-2019-DBMS1-6 - GATE Overflow https://gateoverflow.in/272680/gatebook-2019-...

Admissions (../admissions) 546

Exam Queries (../exam-queries) 541

Tier 1 Placement Questions (../tier-1-placement-questions) 23

Job Queries (../job-queries) 68

Projects (../projects) 19

Recent Blog Comments

(https://gateoverflow.in/blog/4774/?show=7360#c7360)

(https://gateoverflow.in/blog/7349/?show=7359#c7359)
Thanks all
(https://gateoverflow.in/blog/7349/?show=7359#c7359)

Can you also create post about your preparation... (https://gateoverflow.in/blog/7349


/?show=7358#c7358)

Sir, how to enroll for GO classroom (https://gateoverflow.in/blog/7342/?show=7357#c7357)

@Jatin sir,Were you doing job or preparing full... (https://gateoverflow.in/blog/4774


/?show=7356#c7356)

47,810 Questions 52,072 Answers 181,798 Comments


67,377 Users

Send feedback (../feedback) My Marks (../mymarks) College Prediction (../mymarks/ScoreToColleges.php)

Useful Links (../usefullinks) FAQ (../faq) Corrections (../corrections) Discuss (../discuss)

Copyright (../copyright) Request (../request) Testimonials (../blogs/testimonial) Chat Logs (../chatlog)

Chat (../chat) Badges (../badges) Search tips (../search-tips) Exam Category (../exam/categories)

Blog Category (../blog/categories) Blog Tags (../blog/tags) Privacy (../privacy)

 (https://www.facebook.com/GATEOverflow)
 (https://twitter.com/gateoverflow)  (mailto:gatecse@gateoverflow.in)
 (https://plus.google.com/+GateoverflowIn)

Donut Theme (https://github.com/amiyasahu/Donut)  with  by Amiya Sahu


(http://amiyasahu.github.io)

8 of 9 12/02/19, 10:34 am
GATEBOOK-2019-DBMS1-6 - GATE Overflow https://gateoverflow.in/272680/gatebook-2019-...

Powered by Question2Answer (http://www.question2answer.org/)

 GATE Overflow

9 of 9 12/02/19, 10:34 am

Вам также может понравиться