Starting from:

$25

CSE3055 - Database Systems - Homework #3  - Solved

Consider the Turkish Super League database accompanied with this homework.

 

Player (PlayerID: int,   FirstName: nvarchar(25),   LastName: nvarchar(25),   Nationality: varchar(25),   Birthdate: 

smalldatetime,   Age: smallint,   Position: varchar(25)) 

Team (TeamID: int,   Name: nvarchar(50),   City: nvarchar(25)) 

PlayerTeam (PlayerID: int,   TeamID: int,   Season: varchar(5)) 

Match (MatchID: int,   HomeTeamID: int,   VisitingTeamID: int,   DateOfMatch: smalldatetime,   Week: tinyint) 

Goals (MatchID: int,   PlayerID: int,   IsOwnGoal: bit,   Minute: tinyint) 

 1)       Using the backup file TurkishSuperLeague_20211207_StudentVersion.bak accompanied with this homework, restore the database TurkishSuperLeague. Write the following SQL queries, IN A SINGLE STATEMENT, using this database. For each of the following query; save your SQL statements in a text file and take a screenshot of both your SQL query and output of the query on MS SQL Server.

 

2)       Update the field Age for all players.

 

3)       List the “younger” players whose first name does not contain “nec” and play in “Beşiktaş”. “Younger” players are the ones whose ages are less than the average age of all players. Retrieve PlayerID, FirstName + ” “ + LastName.

 

4)       Update all City values of the table Team as: “City” + “ #p” + “Number of players” +” #g” + “Number of goals forward” (e.g. “İstanbul #p25 #g74”). Do not forget to consider own goals in your calculations.

 

5)       List the top 10 top scorers. Retrieve playerID, first name, last name, number of goals scored, number of matches that player did not score a goal, average number of goals per scored matches.

 

6)       Implement a stored procedure sp_GetStandingsUpToDate (aDate) such that exec sp_GetStandingsUpToDate (aDate) computes and shows the standings table, same as in the

following figure, up to the date aDate (inclusive).

Calling with any invalid date causes an error with a message “Invalid date!” All transactions that have been done will be rolled back and stop doing further operations.


More products