Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the following queries in SQL (a) Print all teamIDs where the team played against the Yankees but not against the Braves. (b) Print all

Write the following queries in SQL

(a) Print all teamIDs where the team played against the Yankees but not against the Braves.

(b) Print all tuples (playerID1, playerID2, team1,team2) where playerID1 and playerID2 are not on the same team. Avoid listing self-references or duplicates, e.g. do not allow (1,1,Braves) or both (2,5,Phillies) and (5,2,Phillies).

(c) Print all tuples (teamID1, league1, teamID2, league2, date) where teamID1 and teamID2 played against each other in a World Series game. Although there is no direct information about the World Series games in the relations, we can infer that when two teams from different leagues play each other, it is a World Series game. So, in this relation, league1 and league2 should be different leagues.

(d) List all cities that have a team in only one league. For example, there are currently two leagues (National and American). Although not shown in this instance, New York is home to the Mets in the National league as well as the Yankees in the American league (Chicago also has one in each league, for those of you who are baseball fans). Remember that your query must work over all instances of this schema, even if there are more than two leagues in the instance.

image text in transcribed

image text in transcribed

Players playerName team Javy Lope:z Cliff Lee Derek Jeter Skip Schumaker Cardinals Dominic Brown Phillies position Catcher Pitcher Infielder Infielder Outfielder birth Year 1970 1978 1974 1980 1987 playerlD Braves Phillies Yankees 2 4 5 Teams teamID teamName home leagueName Phillies Philadelphia National

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

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions

Question

3. Identify challenges to good listening and their remedies

Answered: 1 week ago

Question

4. Identify ethical factors in the listening process

Answered: 1 week ago