Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write the following queries in SQL (Note: Your queries must not be state-dependent, that is, they should work without modification even if another instance

1. Write the following queries in SQL (Note: Your queries must not be state-dependent", that is, they should work without modification even if another instance of the database is given.):

(a) Print the names of all players who were born in 1970 and played for the Braves.

(b) Print the names of teams that do not have a pitcher but have a Catcher.

(c) Print names of all players who have played in the National League. (d) Print all gameIDs with Yankees as the guest team.

2. 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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions