Database System Homework #4 Solution

$30.00

Description

Consider the Turkish Super League database that has been e-mailed to you.

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))

player_team (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)

Notes:

Table match stores data only for season 2013-2014. Table goals stores data only for season 2013-2014.

  1. [0 pts] Restore the database TurkishSuperLeague using the file TurkishSuperLeague_20171114.bak that has been e-mailed to you. Write the following SQL queries, in only one statement, using this database. For each of the following query, take a screenshot of both your SQL query and output of the query on MS SQL Server.

  1. [10 pts] Update the field age for all players.

  1. [20 pts] 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.

  1. [30 pts] 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 include own goals in your calculations.

  1. [40 pts] 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.

Compress your screenshots in a zip file. Name it as hw4-lastname-firstname.zip and submit it.

1/1