Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following database consisting of six relations: Beers(name, manf): stores information about beers, including the manufacturer of each beer. Bars(name, city, addr, license, phone):

Consider the following database consisting of six relations:

Beers(name, manf): stores information about beers, including the manufacturer of each beer.

Bars(name, city, addr, license, phone): stores information about bars including their city, street address, phone number and their operating license.

Drinkers(name, city, addr, phone): stores information about drinkers, including their city, street address and phone number.

Likes (drinker, beer): indicates which drinker likes which beers (note that a drinker may like many beers and many drinkers may like the same beer).

Sells (bar, beer, price): indicates the price of each beer sold at each bar (note that each bar can sell many beers and many bars can sell the same beer, at possibly different prices).

Frequents (drinker, bar): indicates which drinker frequents which bars (note that each drinker may frequent many bars and many drinkers may frequent the same bar).

Attribute types: All attributes are of string type (e.g., Drinkers.name can be 'John McDonald'), except Sells.price is a number (e.g., Sells.price can be 2.25). Write SQL queries to answer the following:

Find all bars frequented by both 'Vince' and 'Herb'.

this is what I have:

select distinct bar

from Frequents

where (Frequents.drinker = 'Vince' or Frequents.drinker = 'Herb');

Example Database:

Table: Frequents

drinker bar
Bob Coconut Willie's Cocktail Lounge
Erik Blue Angel
Herb Seven Bamboo
Jesse Blue Angel
John Caravan
Justin Gecko Grill
Mike A.P. Stump's
Mike The Shark and Rose
Rebecca Coconut Willie's Cocktail Lounge
Rebecca Gecko Grill
Tom Blue Angel
Tom Caravan
Vince Blue Angel
Vince Seven Bamboo

Result of your SQL statement:

bar
Seven Bamboo
Blue Angel

Correct Result:

bar
Seven Bamboo

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago