1. Trang chủ
  2. » Công Nghệ Thông Tin

DBI ASSIGNMENT REPORT Student Nguyen Vu Minh Student’s Roll Number SE05309 Class SE1208 Subject Introduction to Databases ( DBI 202) Instructor Ngo Tung Son Table of Contents A Background 7 I General.

64 129 1

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 64
Dung lượng 2,31 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

DBI ASSIGNMENT REPORT Student Nguyen Vu Minh Student’s Roll Number SE05309 Class SE1208 Subject Introduction to Databases ( DBI 202) Instructor Ngo Tung Son Table of Contents A Background 7 I General.

Trang 1

DBI ASSIGNMENT

REPORT

Student: Nguyen Vu Minh Student’s Roll Number: SE05309

Class: SE1208

Trang 2

Table of Contents

A Background 7

I General 7

II Specification: 7

III Destination 7

IV Tools 7

B Preview 8

I Introduce The Premier League 8

II Information for a Premier League Season 9

1 Fixtures 10

2 Results: 11

3 Tables 12

4 Clubs 13

5 Players 14

6 Manager 15

7 Referees 16

8 Match statistics 17

C – Entity Relationship Diagram (Using Chen ‘s Notation) 18

I Business Rules and Assumption Rules 18

1 Business Rules 18

2 Assumption Rules 18

II Entity Relationship Diagram (ERD) for Database 19

1 Simplified Entity Relationship Diagram 19

2 Full Entity Relationship Diagram for Database 20

III Explanations for entities: 21

1 Club: 21

2 Player 22

3 Match Player: 23

4 Fouls 24

5 Card 24

6 Goal: 25

7 Match: 26

8 Referee 27

9 Stadium: 28

10 Manager 28

Trang 3

1 Player – Club: 29

2 Manager – Club: 30

3 Player – Match Player - Match 31

4 Match Player – Foul – Card – Goal 32

5 Stadium – Club - Match 33

6 Match – Referee 34

D Relational Mapping 35

I Step 1: Mapping Regular Entity 35

II Step 2: Weak entities handling: 36

III Step 3: Sub – entities handling: 36

IV Step 4: 1 – N (1 to many) relationships handling: 36

V Step 5: 1 – 1 relationship handling: 37

VI Step 6: Many to many (M - N) relationships handling: 38

VII Muli – part and multi – value handling: 38

E Logical Design 39

I Relational Schema 39

II Database Diagram 40

III Table Analysis 41

1 Stadium: 41

2 Player 42

3 Referee 43

4 Card 44

5 Manager 44

6 Club 45

7 Player_Club 46

8 Manager_Club 47

9 Match 48

10 MatchPlayer 49

11 Foul 50

12 Goal 51

IV Database statements used to create table 52

1 Stadium table 52

2 Player table 52

3 Referee table 52

4 Card table 53

Trang 4

6 Club table 53

7 Player_Club table 53

8 Manager_Club table 54

9 Match table 54

10 MatchPlayer table 55

11 Foul table 55

12 Goal table 55

F Queries, Store Procedures and Trigger 56

I Sample Queries 56

1 Query using ORDER BY 56

2 Queries using INNER JOIN 57

3 Queries using aggregate functions: 59

4 Queries using GROUP BY and HAVING clauses: 60

5 Queries that use sub – queries as relation 61

6 Queries that use sub-query in the WHERE clause: 62

7 Queries that use partial matching in the WHERE clause: 63

8 Queries that use self-join: 64

Table of Image Figure 1: The Premier League Information

8 Figure 2: Premier League Season information

9 Figure 3: Premier League Fixtures

10 Figure 4: Premier League Results

11 Figure 5: Premier League 2017 – 2018 Tables

12 Figure 6: Premier League Clubs

13 Figure 7: Premier League Players

14 Figure 8: Premier League Managers

Trang 5

Figure 9: Premier League Referees

Trang 6

Figure 30: Result of query using order by

Figure 34: Result of query using GROUP BY and HAVING clause

60 Figure 35: Result of query using sub query as

Trang 7

A Background

1 Design and develop a database system for a sport tournament season

2 The database must consist of at least six tables populated with data

3 The database is to support queries that would typically be submitted to the system for the topical chosen area

4 Using Chen’s Notation for Entity Relationship Diagram (ERD)

5 Map the EER model into a relational data model normalized at least 3rd normal Form

6 Using appropriate SQL commands create a set of database tables in MS SQL Server 2008+ You should also show all constraints used in the creation of the tables

Design and develop a database

system for English Premier League 2017 – 2018

IV Tools

1 Microsoft SQL DatabaseManagement Studio 2016

2 Microsoft Visio 2016Professional

3 Microsoft Word 2016Professional

Trang 8

association football clubs At the top of the English football league system, it is the country's primary football competition Contested by 20 clubs, it operates on a system of promotion and relegation with the English Football League Welsh clubs that compete in the English football league system can also qualify Welsh clubs that compete in the English football league systemcan also qualify

The Premier League is a corporation in which the 20 member clubs act as shareholders Seasons run from August to May Teams play 38 matches each (playing each team in the league twice, home and away), totaling 380 matches in the season. Most games areplayed on Saturday and Sunday afternoons; others during weekday evenings It is colloquially

known as the Premiership and outside the UK it is commonly referred to as the English

Premier League (EPL)

In total, 49 clubs have competed since the inception of the Premier League in 1992 Six of them have won the title: Manchester United

(13), Chelsea (5), Arsenal (3),

Manchester City (2), Blackburn

Rovers (1) and Leicester City (1)

Figure 1: The Premier League Information

(Source: Wikipedia ( https://en.wikipedia.org/wiki/Premier_League) )

II Information for a Premier League Season

A Premier League season contains a lot of information that must be stored Below isthe most necessary

Trang 9

Figure 2: Premier League Season information

In fact, a Premier League season has much more information than above one such as broadcast rights, transfers, tickets, safeguarding or lots of other However, to simplify the work of designing and developing databases system as well as the structure of database, I will only concentrate on the main information that I listed above

(Source: https://www.premierleague.com/home)

Trang 10

1 Fixtures

In order to control the matches time for broadcast, transfers purpose or fitting with all other events like Christmas, New Years, World Cup Qualifiers, etc., before the first game, the fixtures are made for a whole season – usually from August to May

The fixtures contain lots of records Each record includes information of a match that has been scheduled: home team, guest team, date and time that the match will be played, the stadium where the match will be hold

Figure 3: Premier League Fixtures

(Source: https://www.premierleague.com/fixtures )

2 Results:

Results is one of the most information of a football match The results are the status win, lose or draw, the score of home and away team The winner will receive 3 points, the

Trang 11

Figure 4: Premier League Results

(Source: https://www.premierleague.com/results )

3 Tables

After a match, each teach will get their corresponding point (3 points if win, 1 point if draw and 0 point if lose) This point will be statistics to create tables The tables will be updated after a match and will show ranking of each team in the league The tables usuallycontain club name with their position, how many game that played, games they won, drawn and lost, number of goals for, goal again, goal different, their point and their recently form

Trang 12

Figure 5: Premier League 2017 – 2018 Tables

(Source: https://www.premierleague.com/tables )

4 Clubs

In the Premier League history, there are many different clubs that had competed at thisleague, but in this assignment, I will only concern about the most recently season, the Premier League 2017 – 2018 So, there are only have 20 clubs compete at this league this season A club information includes their name, their address, their stadium, their CEO, etc

Trang 13

Figure 6: Premier League Clubs

(Source: https://www.premierleague.com/clubs )

5 Players

The Premier League has many players that come from many different nations in the world The player will play for a club for a certain time according to the contract between the club and player One player can only play for one club at one time but he can play for more than one club at the season if he moves to another club at the transfer time The player information includes their name, date of birth, weight, height, position, nationality, etc

Trang 14

Figure 7: Premier League Players

(Source: https://www.premierleague.com/players )

6 Manager

Like player, managers come from many different country and will manage a club in a certain time corresponding to the contract between the manager and the club A manager could also manage different team in a season but only one club at one time A manager information includes their name, nationality and the club they manage

Trang 15

Figure 8: Premier League Managers

Trang 16

Figure 9: Premier League Referees

Trang 17

Figure 10: Premier League Match Statistics

(Source: https://www.whoscored.com/Matches/1190228/Live/England - Premier -

League - 2017 - 2018 - Manchester - City - Burnley )

C – Entity Relationship Diagram (Using Chen ‘s Notation)

1 Business Rules

1 There are 20 clubs play at Premier League each season

2 Each team must have player to play at Premier League

3 One team can have 25 players in maximum

4 Player must belong to a club

Trang 18

5 Player can only play for one club at one time but during the season, they can play for morethan one club if they move to another club at the transfer time

6 One club must have one manager

7 A manager can only manage one club at one time but they can move to other club at transfer time

8 A squad for a match contains 16 players in maximum (11 for line-up and 5 sub players)

9 In a match, a club can sub 3 players in maximum 10 Each club owns a stadium and a stadium belongs to a club

11 A match is between 2 club, a host club and a guest club

12 A match always plays at stadium of host club

13 A match is taken charge by a referees

14 A player could receive 2 yellow cards in maximum

15 2 Yellow cards equivalent 1 red card Player received 2 yellow cards or 1 red card in a match will be kicked out of that match

16 A goal can score by any time in match The time always between 1 and 90

2 Assumption Rules

1 A player, Manager, Referee using a positive integer for identifier instead of their SSN

2 One team manage by only one manager, the main one

3 One match is taken charge by one referee, the main one

4 The type of player is only one of these values: Goal keeper, Defender, Midfielder, Forward

II Entity Relationship Diagram (ERD) for Database

1 Simplified Entity Relationship Diagram

Trang 19

Figure 11: Simplified ERD for Premier League 2017 – 2018

2 Full Entity Relationship Diagram for Database

Player N Play for N Club N Manage N Manager

Time

Trang 20

Figure 12: Full ERD for Premier League 2017 – 2018

III Explanations for entities:

1 Club:

Club ClubID

ClubName

Number of players

Trang 21

Figure 13: Club entity

- Definition: A club is a group of people formed for the purpose of playing football In the

English Premier League 2017 – 2018, there are 20 clubs compete The maximum players that each club can have are 25 (maximum 17 foreign players (this rule are ignored in this report)) A club at Premier League is usually owned by a CEO or an organization

However, in this report, I will ignore that information

- Attributes of Club: Club ID, Club Name, and may be number of players in the club

- Club ID usually is a 3-character of club name Club ID is unique and using to identify a club

 This is primary key for the Club entity

- Number of players is derived attribute because it can be count easily

Height

ShirtNo

Trang 22

- Definition: Player is the one who directly play a match in the Premier League To play at

this league, player must have a legal contract with one of 20 clubs play at Premier League

of that season, for this report is 2017 – 2018 season

- Attributes of Player: Player ID, Name, DOB, Nationality, Height, Position and Shirt Number

- One player has his ID to differ from other players In fact, a player has his unique SSN to identity them but to simply find the process of collecting data, I will use Player ID instead

Player ID is just a positive integer and one player has one ID

 PlayerID is primary key for player entity

- A player can come from many different countries but a club can’t have more than 17 nonEnglish players

3 Match Player:

Figure 15: Match player entity

- Definition: A club could include 25 players in maximum but in a match, a club could only

register 16 players (11 players for lineup and 5 sub players) However, in a match, a player

could only sub 3 players in total

Trang 23

- Attributes: A match player include some information: number of shots, the percentage of

pass success, number of dribbles, number of aerials won, number of tackles, running

distances I also add a ID attributes to identify each record

 ID is primary key for Match Player entity

- In fact, a match player can divide into many types: goal keeper, defender, midfielder, forward with different attributes for each type But in this assignment, I will not divide Match Player into that types

4 Fouls

Figure 16: Foul entity

- Definition: In a match, there are many different foul such as kicking, tripping, charge into, pushing an opponent, offside, touch the ball with hands

- Attributes: ID, type of fouls

 ID is primary key for this entity

5 Card

Figure 17: Card entity

Foul

ID Type

Card

ID Color

Trang 24

- Definition: In a match, player can receive card from referee for commit foul or other not

bad behavior There are two type of card: yellow card and red card Two yellow cards equivalent to a red card If player receive a red card, they can’t continue to play match

- Attributes: ID, color of card

 ID is primary key for this entity

6 Goal:

Figure 18: Goal entity

- Definition: Goal is the most important part of a match A goal could be made by many

different part of player’s body such as left foot, right foot, head, chest - Attributes:

Goal ID, type of goal, minute, offset

 GoalID is primary key for Goal entity

- There are many different types of goal but I this assignment, I assume that there only threetypes of goal: directly goal (a goal make by player of …), penalty goal, own goal

- Offset attribute show the extra minutes when the goal is scored By default, the offset is 0

Trang 25

Figure 19: Match entity

- Definition: In Premier League and all other football league in the world, a match includes

clubs (1 home clubs and 1 away club) The result of the match is calculated by the host score and the guest score If the host score equal to the guest score, the match is drawn Otherwise, the club score more is the winner

- Attributes: Date of the match, status of the match (scheduled, postponed, playing,

finished), the host and guess score

- This is a week entity that can have its attribute to make a primary key Match use 2 foreignkey from club table (the home club ID and the away club ID) with the attribute Date to form a primary key

 Primary key is combine of hostID, awayID and date

Trang 26

Figure 20: Referee entity

- Definition: Usually there are four referees in a match, one main referee, two assistant

referees and one fourth referee However, in this assignment, I will only care about the main referee and will ignore all other referees Main referee is the one who has highest authority to decide a situation in a match A referee information contains name,

nationality, number of experienced years and will take charge of which match

- Attributes: Referee ID, Name, Nationality

- Like player entity, referee has their own SSN to identity but to simplify the work of collecting data, I just use a positive integer for each record in the referee entity

 Referee ID is the primary key

9 Stadium:

Figure 21: Stadium entity

- Definition: Each club plays in the Premier League has their own stadium This stadium

holds the match between the club own it as a home team and another team as an away

Trang 27

- Attributes: Stadium ID, Name, Address and Capacity

- Stadium ID is just a positive integer using to identity each record in the table  StadiumID

is primary key

10 Manager

Figure 22: Manager entity

- Definition: Each club is coached by a manager Actually, a club could have many

manager (1 main coach and many other assistant coaches) But in this assignment, I assume that one club has only one coach, the main one

- Attributes: Manager ID, Name and Nationality

- Manager ID is a positive integer and it’s unique

 ManagerID is primary key for Manager entity

IV Explanation for Entity Relationships:

Trang 28

Figure 23: Player – Club Relationship

- One player only plays for one club at one time, but in a season he can play for many club if he moves from one club to another one at the transfer time One club can have many players (maximum 25 player) If a player wants to play for a club or the club want one player plays for their team, they must sign a contract A contract contains information of player and clubs that they play for It also contains the start date and end date of a contract, the salary that player will have during the time he plays for the club

- There is no club that have no players play at Premier League and there a no player who does not play for any club at Premier League stored

Trang 29

Figure 24: Manager – Club Relationship

- Like player, manager only coaches one club at one time but during the Premier League season, they can coach many different clubs if they move to another club the at thetransfer time During the season, one club could have different manager so one club have many manager and one manager can coach many clubs too If manager want coach a club

or a club want a manager coach their team, they must sign a contract A contract contains information of both side, the start date and end date of the contract

- In the Premier League, there is no club have no manager and there are no manager thatnot coach any team stored

3 Player – Match Player - Match

Trang 30

Figure 25: Player – MatchPlayer - Match Relationship

- A club contains 25 players in maximum but not all of them can play in a match In the Premier League, a squad for a match contains 16 players in maximum (11 players for lineup

and 5 sub players) A Match player must be a player but a player might not be a match player

In a match, a club can sub maximum 3 players but it not requires A club could not change anyplayers or not use all of 3 times change player

- A match player must play for a match and a match must contain match player No

match plays if not have player and there is no match player that not play for match

4 Match Player – Foul – Card – Goal

Player

Match

MatchPlayerbe

inN

1

Sub

1

Trang 31

Figure 26: MatchPlayer – Foul – Card- Goal Relationship

- In a match, a match player can commit a foul and also receive a foul A committed foul can be different in type and could commit on some other player or not So a foul could be receive by a player or not If a player commits a fouls, depend on the rules, the player may receive a card (yellow card or red card)

- In a match, match player a scores one or many goal but can also scores no goal Each goal can by assist by some else player or not No goal exist that not scored by players

5 Stadium – Club - Match

N

1 N

Trang 32

Figure 27: Stadium – Club - Match Relationship

- Every club in the Premier League 2017 – 2018 owned a stadium and every stadium that stored is owned by a club There is no club that don’t have any stadium and there is no stadium that stored isn’t owned by any club

- All matches in the Premier League 2017 – 2018 include 2 team (a host team and a guest team) Host team will host the match at their own stadium No match plays that don’t have host and guest team

Ngày đăng: 08/11/2022, 00:02

TỪ KHÓA LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w