Question

In: Computer Science

Consider the following relational model for a basketball league: • Player (PlayerID, PName, Position, TeamID) •...

Consider the following relational model for a basketball league:

• Player (PlayerID, PName, Position, TeamID)
• Team (TeamID, TeamName, Venue)
• Game (GameNo, Date, Time, HomeTeamID, AwayTeamID)
• Record (GameNo, PlayerID, Points, Rebounds, Assists)

In this basketball league, each team has a unique name and each player plays for only one team. One team has at least 10 players. Two teams (home team versus away team) participate in each game at home team’s venue. Each team meets all other teams twice (i.e., double round-robin tournament), one time as home team and the other time as away team. For each game, the league records points, the number of rebounds and the number of assists for each player. If a player did not play for a game, there is no record for this player in that game.
Question 1a.Draw an ER-diagram model for the basketball league. (The relationship between two entities should be 1-to-1, 1-to-many, many-to-1 or many-to-many.)[20 marks]

1.All relationships are total participations.

2.PlayerID, TeamID and GameNo are unique attributes.

3.The relationship between Player and Team is 1-to-many relationship.

4.The relationship between Team and Game is many-to-many relationship.


Question 1b. Write a SQL to retrieve the distinct TeamID and TeamName of teams that have at least one game where the team participated as the home team getting more points than all the games where that team participated as the away team. [20 marks]

Question 2. Write a SQL to retrieve the PlayerID, PlayerName and Points of the players who achieve the highest point in a game. [20 marks]

Question 3. Write a SQL to retrieve the GameNo, TeamName, total points and total number of rebounds of a team (either home team or away team only) for each game and the team has the total number of rebounds in that game larger than 30. For a game, both teams, only home team, only away home, or none of both teams has total number of rebounds larger than 30 in that game. [20 marks]

Solutions

Expert Solution

1(a)

1(b)
select distinct TeamID,TeamName from Team where TeamId in
(select HomeTeamId in Game where Game.HomeTeamId = Team.TeamId and GameNo in
(select GameNo from Record where Game.GameNo = Record.GameNo and Record.Points >
(select max(Points) from Record where GameNo in(select GameNo from Game where Game.GameNo = Record.GameNo and AwayTeamId in (select TeamId from Team)))
);


(2)
select Player.PlayerID, Player.PlayerName, Record.Points from Player,Record where Player.PlayerId = Record.PlayerId and Record.Point > max(Record.Points);

(3)

(// FOR HOMETEAM ONLY)

select Game.GameNo,Team.TeamName,sum(Record.Points)as totalPoints, sum(Rebounds) as totalRebounds from Game,Team,Record where Game.HomeTeamId = Team.TeamId and totalRebounds > 30;

(// FOR AWAYTEAM ONLY)

select Game.GameNo,Team.TeamName,sum(Record.Points)as totalPoints, sum(Rebounds) as totalRebounds from Game,Team,Record where Game.AwayTeamId = Team.TeamId and totalRebounds > 30;


Related Solutions

Jason "Sharp Shooter" Averson is a basketball player in the major league. He has a free...
Jason "Sharp Shooter" Averson is a basketball player in the major league. He has a free throw success rate of 0.63. Find the probability that from a random sample of 28 free throws, Jason is successful, i.e. scores, on 18 or more throws. You may find this standard normal table useful. Give your answer as a decimal to 3 decimal places. Probability =
Draw a relational model for the following case study. Case Study The local under-sixteen football league...
Draw a relational model for the following case study. Case Study The local under-sixteen football league needs a database to help track teams, children that sign up to play in the league, the parents of these children and the coaches for each team. The league wishes to record the details for each parent of a particular player (the parents last name, first name, phone contact number and address). For each player, the system needs to record the player's last name,...
Given a relational database that consists of the following relations: Performer (pid: integer, pname: string, years_of_experience:...
Given a relational database that consists of the following relations: Performer (pid: integer, pname: string, years_of_experience: integer, age: integer) Movie (mname: string, genre: string, minutes: integer, release_year: integer, did: integer) Acted (pid: integer, mname: string) Director (did: integer, dname: string, earnings: real) Do the following using your Azure SQL database: a) Use SQL statements to create the relations. b) Populate the relations using SQL statements with the given data posted on Canvas. c) Implement the SQL queries for the following:...
The National Basketball League is a professional sports league in North America. Each team in the...
The National Basketball League is a professional sports league in North America. Each team in the league must participate the revenue sharing system. For the purposes of the revenue sharing plan, there are no limits to the amount each team may contribute to the plan. Each team is subject to a receipt limits based their designated market area (DMA). For teams with a DMA between 1.5-2.249 households, the final receipt limit is set at 75% of the initial receipt; for...
Find the PMF where two players, Player A & Player B are playing basketball. Player A...
Find the PMF where two players, Player A & Player B are playing basketball. Player A goes 1st and has probability p1 of making a basket on any throw. Player B, who shoots second, has probability p2 of making a basket. The outcomes of the successive trials are assumed to be independent.
HR Slugger is a professional baseball player in a Major League Baseball league. He is a...
HR Slugger is a professional baseball player in a Major League Baseball league. He is a well-known player and is very popular throughout the league, but especially with the local fans. Much of his population is based on his hitting ability, specifically regarding home runs. The issue emerges from the following facts, similar to an actual situation you may have heard of. • After days of intense anticipation by sports fans and winters throughout the league, Slugger hits a home...
Soma recorded in the table the height of each player on the basketball team Basketball Players’...
Soma recorded in the table the height of each player on the basketball team Basketball Players’ Heights (in inches) 66 66 68 57 64 65 67 67 64 65 Construct a normal probability distribution curve for this population! Indicate the number for the mean, 1SD, 2SD and 3SD (both sides of the mea) (1+ 6*0.5=4p)
A basketball player is 6ft tall, the player was fouled and gets a free shot from...
A basketball player is 6ft tall, the player was fouled and gets a free shot from the foul line. The player is 15ft away from the basketball net, and the basket is 10ft off the ground. a)If the basketball player shoots the ball at an angle of 45 degrees, find the magnitude of the velocity needed to get the ball into the basket b) If a basketball has a mass of 1kg estimate the force as a vector needed to...
A basketball player completes a free throw 80% of the time. In practice the player goes...
A basketball player completes a free throw 80% of the time. In practice the player goes to the free throw line     and takes 5 shots in a row.     a)   Make a table showing the probability distribution of successes and their probabilities     b)   Draw the probability histogram. c) What is the shape of the distribution? d) What is the mean?     e) What is the standard deviation?
Basketball player Michael's weight averages about 190 pounds during basketball season.
INSTRUCTIONS: Please provide your answer in a thought-out, coherent essay and use complete sentences. Basketball player Michael's weight averages about 190 pounds during basketball season. He never thought he needed to take a multivitamin and mineral supplement since he is healthy and eats a variety of foods. Michael just took a nutrition course about vitamins and minerals and what they do for the body. He is considering taking a supplement just for the insurance. He uses up a lot of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT