Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. There are 4 relations in the schema, which are described below along with their integrity constraints. Columns in the primary key are underlined. Player(

5. There are 4 relations in the schema, which are described below along with their integrity constraints. Columns in the primary key are underlined.

Player(playerID: integer, name : varchar(50), position : varchar(10), height : integer, weight : integer, team: varchar(30))

Each Player is assigned a unique playerID. The position of a player can either be Guard, Center or Forward. The height of a player is in inches while the weight is in pounds. Each player plays for only one team. The team field is a foreign key to Team.

Team (name: varchar(30), city : varchar(20))

Each Team has a unique name associated with it. There can be multiple teams from the same city.

Game (gameID: integer, homeTeam: varchar(30), awayTeam : varchar(30), homeScore : integer, awayScore : integer)

Each Game has a unique gameID. The fields homeTeam and awayTeam are foreign keys to Team. Two teams may play each other multiple times each season. There is an integrity check to ensure homeTeam and awayTeam are different.

GameStats (playerID : integer, gameID: integer, points : integer, assists : integer,
rebounds : integer)

GameStats records the performance statistics of a player within a game. A player may not play in every game, in which case it will not have its statistics recorded for that game. gameID is a foreign key to Game. playerID is a foreign key to Player. Assume that two assertions are in place. The first is to ensure that the player involved belongs to either the involving home or away teams, and the second is to ensure that the total score obtained by a team (in Game) is consistent with the total sum (in GameStats) of individual players in the team playing in the game[2].

Write out SQL statements for the following 10 queries.

Note: You are asked to order the result of each query by some attribute(s) using keyword ORDER BY - you need to find out its usage by yourself.

3) List all distinct (player name, team name) pairs of players and their teams, where the player name contains "Mark" and the team is located in a city whose name starts with "B" or "C" or "L". (ORDER BY Player.name, Team.name) Hint: You'll need to use the 'LIKE' predicate operator.

select list: Player.name, Team.name

ordering: Player.name ascending, Team.name ascending

4) For each city that has at least one NBA team, list the city name and the height of the tallest player playing the "Center" position in that city. (ORDER BY Team.city).

select list: Team.city, max_center_height

ordering: Team.city descending

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

Students also viewed these Databases questions

Question

Classify delivery styles by type.

Answered: 1 week ago