Question 2 Recall the Beers database and some (approximate) table definitions from that database: create table Beers (name text primary key, brewer text); create table Drinkers (name text primary key, address text, phone text );

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Question 2,
Recall the Beers database and some (approximate) table definitions from that database:
create table Beers (name text primary key, brewer text );
create table Drinkers (name text primary key, address text, phone text);
create table Likes (drinker text references Drinkers (name),
Which of the following queries (maybe more than one) answers the question "Which drinkers like every beer?"
Note that there may be no drinkers that satisfy this property in the original instance of the database.
(a) O
(b) O
(d) O
(e) O
select d.name
from
where
beer text references Beers (name),
primary key (drinker, beer) );
Drinkers d
not exists (
(select L.beer as name from Likes L where L.drinker = d.name)
);
select d.name
from Drinkers d
where
);
except
(select name from Beers)
not exists (
(select name from Beers)
except
(select L.beer as name from Likes L where L.drinker = d.name)
select d.name
from
Drinkers d
where (select count(*) from Beers)
(select count (L.beer) from Likes L where L.drinker = d.name);
);
select d.name
from Drinkers d
where
exists (
(select L.beer as name from Likes L where L.drinker = d.name)
except
(select name from Beers)
None of above options is correct
Transcribed Image Text:Question 2, Recall the Beers database and some (approximate) table definitions from that database: create table Beers (name text primary key, brewer text ); create table Drinkers (name text primary key, address text, phone text); create table Likes (drinker text references Drinkers (name), Which of the following queries (maybe more than one) answers the question "Which drinkers like every beer?" Note that there may be no drinkers that satisfy this property in the original instance of the database. (a) O (b) O (d) O (e) O select d.name from where beer text references Beers (name), primary key (drinker, beer) ); Drinkers d not exists ( (select L.beer as name from Likes L where L.drinker = d.name) ); select d.name from Drinkers d where ); except (select name from Beers) not exists ( (select name from Beers) except (select L.beer as name from Likes L where L.drinker = d.name) select d.name from Drinkers d where (select count(*) from Beers) (select count (L.beer) from Likes L where L.drinker = d.name); ); select d.name from Drinkers d where exists ( (select L.beer as name from Likes L where L.drinker = d.name) except (select name from Beers) None of above options is correct
Question 1
Consider the following table definitions:
create table x ( id integer primary key, name text unique );
create table y (id integer primary key, x_id integer references x(id), defn text );
Which of the following SQL queries will return a list of names of x's and a count of the number of y tuples each is associated with?
There may be more than one correct answer.
(a) O
(b) 0
(c)
(d) O
(e) O
(f) O
select x.name, count (y.id)
from x join y on (x.id = y.x_id)
group by x. name;
select x.name, count (y.id)
from x left outer join y on (x.id = y.x_id)
group by x.name;
select x.name, count (y.id)
from x right outer join y on (x.id = y.x_id)
group
by x. name;
select x.name,
(select count(x_id) from y where y.x_id = x.id) as count
from x full outer join y on (x.id = y.x_id);
select distinct x.name,
from
(select count (x_id) from y where y.x_id = x.id) as count
x full outer join y on (x.id = y.x_id);
None of the above is correct
Transcribed Image Text:Question 1 Consider the following table definitions: create table x ( id integer primary key, name text unique ); create table y (id integer primary key, x_id integer references x(id), defn text ); Which of the following SQL queries will return a list of names of x's and a count of the number of y tuples each is associated with? There may be more than one correct answer. (a) O (b) 0 (c) (d) O (e) O (f) O select x.name, count (y.id) from x join y on (x.id = y.x_id) group by x. name; select x.name, count (y.id) from x left outer join y on (x.id = y.x_id) group by x.name; select x.name, count (y.id) from x right outer join y on (x.id = y.x_id) group by x. name; select x.name, (select count(x_id) from y where y.x_id = x.id) as count from x full outer join y on (x.id = y.x_id); select distinct x.name, from (select count (x_id) from y where y.x_id = x.id) as count x full outer join y on (x.id = y.x_id); None of the above is correct
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY