0% found this document useful (0 votes)
43 views21 pages

Bangladesh Cricket Board Database-1

The document outlines the creation of a database for the Bangladesh Cricket Board using SQL, detailing the structure of five tables: Players, Venues, Teams, Matches, and Match Statistics. It explains the use of various SQL commands for data manipulation, including aggregate functions, joins, and data backup techniques. Additionally, it discusses the implications of foreign key constraints on data integrity when records are deleted.

Uploaded by

Maisoon Mamun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views21 pages

Bangladesh Cricket Board Database-1

The document outlines the creation of a database for the Bangladesh Cricket Board using SQL, detailing the structure of five tables: Players, Venues, Teams, Matches, and Match Statistics. It explains the use of various SQL commands for data manipulation, including aggregate functions, joins, and data backup techniques. Additionally, it discusses the implications of foreign key constraints on data integrity when records are deleted.

Uploaded by

Maisoon Mamun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Maisoon Mamun

2120468
Bangladesh Cricket Board
Database
16th December 2023
MIS401
Introduction

A database is a collection of data that is stored, organized and accessed. DBMS (Database
Management System) is a software application that enables the creation, organization, retrieval,
and management of data in a database. It provides users with tools to define the structure of the
database, control access to the data, and execute SQL (Structured Query Language)
statements to manipulate and query the data. We are going to create a database about
Bangladesh Cricket Board which will consist of 5 tables about 5 entities that contain attributes of
each entity using SQL.

- Primary Key

- Attribute

- Foreign Key

Players Table

player_id name DOB role highest_score contact_number

121 abc 1985-09-01 batsman 202030 134562341

122 bde 1982-04-04 bowler 2341123 142345123

123 fgh 1981-03-12 batsman 455367 152341234

124 ijk 2000-05-02 all-rounder 54657675 153214357

125 lmn 1999-11-12 all-rounder 345135 132456749

126 opq 1998-11-01 bowler 6789005 142342451

127 rst 1997-10-12 bowler 90034562 192345543

128 uvw 1992-12-13 batsman 67884 182334678

Venues Table

venue_id name location capacity

101 Sher-e-Bangla Mirpur, Dhaka 26000


Cricket Stadium

102 Zohur Ahmed Pahartali, Chittagong 22000


Chowdhury Stadium

103 Sylhet International Lakkatura, Sylhet 18500


Cricket Stadium

Teams Table

team_id name type captain_player_id coach_player_id

111 def regional 121 124

112 ghi club 123 125

113 jkl regional 128 125

114 mno national 125 124

Matches Table

match_id format date venue_id home_tea away_tea result


m_id m_id

1 T20I 2015-01-03 101 113 111 draw

2 ODI 2015-01-04 103 114 113 draw

3 ODI 2015-01-05 103 112 114 112 won

4 T20I 2015-01-06 101 111 114 114 won

5 Test 2015-01-07 102 111 112 111 won

Match Statistics Table

match_id player_id runs_scored wickets_taken catches_taken

1 121 300 460 130

2 122 200 450 120

3 123 350 430 150

4 124 450 200 200

5 125 500 300 240


To create the tables, you must first need to create the database named BCB which stands for
Bangladesh Cricket Board.

However simply creating the database BCB isn’t enough as tables won’t be created if you don’t
use that database. This sql command will let you start creating the tables.

Then start creating the tables named Players, Venues, Teams, Matches and Match Statistics.
Use the following command to create these tables.

Players
Venues

Teams
Matches

Match Statistics
Then insert the records in each table using the following sql command for the Players table.
Do the same for the Venues, Teams, Matches and Match Statistics tables.
Aggregation Functions

Suppose you want to find the average cricket runs scored in the match statistics table. Use the
avg command to obtain the result.
To find out the total runs scored from the match statistics table, use the sum function.

To determine the number of players participating in cricket matches, use the count function.
You can also use the count function to determine the number of players participating in cricket
matches born before 2000.

Count function can even be used to count the number of matches with certain formats instead of
counting manually.
To calculate the criteria of the total highest scores of the players of above 10000, use the having
clause.

Use the max and order functions to find out the players with the highest and the lowest scores.

Union
To turn players’ names into teams by uniting the team names with the player names from the
teams and players tables respectively, use the union command.

Like
Suppose you want to find out which players are bowlers, batsmen and all-rounders. Instead of
searching each record which can be time-consuming, use the like keyword to find them out.

Use the like command to find the record in the venues table where the name of the venue is
Zohur Ahmed Chowdhury Stadium.

Between

To find the players whose highest score lies between 10000 and 70000, use the between
command.
Join

To check which matches take place in which venues in which format, use the left or right join
commands.

Insert Into Select


In order to use this command on the teams table, first create a backup teams table.
Then use the insert into select statement to copy data about Team ID and Name from the teams
table to the backup teams table.
Create another backup table for teams but this time use the insert into select command for the
club type only.

On Delete
To ensure the Teams and the Match Statistics child tables are connected to the Players mother
table, let’s delete the player_id 121 from the mother table to see how it affects the child tables.

As you can see, the captain_player_id foreign key in the Teams table was set to ’on delete set
null’ which means only the captain_player_id 121 is set to null as that player_id in the Players
mother table has been deleted whereas the player_id foreign key was set to ‘on delete cascade’
which means deleting the player_id 121 from the Players table deleted the entire row regarding
this player_id from the Match Statistics table.

Conclusion

I demonstrated that SQL is a coding language that acts as a DBMS for creating, structuring and
manipulating data in a database through the use of queries. The queries used for demonstrating
this are aggregate functions such as count, sum, avg and max to obtain certain numbers such
as the number of players participating in Bangladesh Cricket Board, number of players born
before 2000, total and average runs scored, total highest score, maximum highest and lowest
scores, number of matches in T20I, ODI and Test formats as well as the like keyword for finding
out which players are bowlers, batsmen and all-rounders and finding out more information about
the venue named Zohur Ahmed Chowdhury Stadium. I fused the team and player names to a
single list of team names using the union command. I used the between command to find out
the records that are between certain numbers. Then I used the join command to join entities
from different tables to see how interrelated these tables are. Not only do queries help in
manipulating data to find out the needed results but they can also be used to backup data in
case the original data becomes lost using the insert into select statement which is used after
creating a backup table where data from the original table can be copied to this table like how I
copied the original Teams table data to the Backup Teams table that I created afterwards. Then I
differentiated between the ‘on delete set null’ and ‘on delete cascade’ commands used when
creating a foreign key that references another table by deleting one record from the mother
table to see how differently it affected the child tables.

You might also like