0% found this document useful (0 votes)
66 views32 pages

Ip Project 1

Uploaded by

gg1388334
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)
66 views32 pages

Ip Project 1

Uploaded by

gg1388334
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/ 32

Jagjeetpur, Haridwar

Project : Sports Management System


2024-25

Submitted By : Submitted To :

Lakshya Rawat Mrs. Sandhya Thakur

Mukesh Bhatt

Gaurav Shah
.

ACKNOWLEDGEMENT

I would like to take this opportunity to express my gratitude to those who have
been of great assistance in finishing this project in due course of the stipulated
deadline. To begin with, I would like to thank Principal ma'am, Mr. Rajesh
Kumar Sharma for her encouragement and for providing me with all the
required facilities for completing my project.

I extend my heartfelt thanks to Mrs. Sandhya Thakur, our Informatics Practices


teacher, who guided me in successful completion of this project. I take this
opportunity to express my deep sense of gratitude for her invaluable guidance,
attitude and immense motivation, which has sustained my efforts at all stages
of this project work.

I would also acknowledge my gratitude towards my classmates for having been


a source of inspiration and for their patience in resolving what I couldn't grasp
efficiently. I thank them earnest for correcting me where I erred and their
recommendations. I thank them all for expanding my interest in the study that
is programming.

At last I would like to thank my parents for constantly pushing me and


motivating me to do my best

Submitted by :

Lakshya Rawat
CERTIFICATE

Project Title: Sports Management System

This is to certify that Lakshya Rawat a student of Class 12 Commerce, has


successfully completed the project titled Sports Management System under
the guidance of Mrs. Sandhya Thakur , as part of the academic curriculum
for the year [Year].

The project demonstrates a comprehensive understanding of various


business management techniques and practices within the context of sports.
The student has diligently worked on the design and functionality of the
system, which includes features such as player registration, event
scheduling, score tracking, and team management.

This project was submitted for evaluation as part of the final academic
assessment and reflects the student’s hard work, creativity, and analytical
skills.

Instructor's Signature: ____________________


Principal's Signature: ____________________
School Name: Divine Light School, jagjeetpur Haridwar
SYNOPSIS

The Sports Management System project deals with registering new


members, plans, payments, routine and managing the members for
the. The project has complete access for the crud operations that are
to create, read, update, and delete the database entries. At first you
need to login as this system is totally controlled by the admin/owner
and then register the members for and check their health status and
view the total income per month. Now you can assign different routine
to different members and check the health status which can be
viewed and edited too and finally check the payments according to
the plan they have chosen.

It has a database administration that has access to the entire


database, in regards with viewing, updating, and deleting the
information.
INTRODUCTION

The Sports Management System project deals with registering new members,
plans, payments, routine and managing the members for the. The project has
complete access for the crud operations that are to create, read, update, and
delete the database entries. At first you need to login as this system is totally
controlled by the admin/owner and then register the members for the and check
their health status and view the total income per month. Now you can assign
different routine to different members and check the health status which can
be viewed and edited too and finally check the payments according to the plan
they have chosen.

It has a database administration that has access to the entire database, in


regards with viewing, updating, and deleting the information.

1.1 PROJECT OBJECTIVE

The Sports Management software is very user friendly and appealing. The
Human objective of the system is to maintain and retrieve information about
the members and the sports they will play on which day of the week and at what
time in the sports. The system is simple in design and implementation. The
main objectives of this system can be summarized as follows:

Design of a GUI portal for managing the Sports for the main admin/owner.
Insertion of member's data plans and managing of payment and health status.

Monthly Payment for monthly plan and yearly payment of yearly plan.

Computerized manipulation and management of member data and id. Easy


management of databases of various sections covering key aspects

1.2 PROJECT OVERVIEW


1.3.1 MODULES DESCRIPTION

i) ADMIN MODULE

In this module admin check after all details about sports players and the player
list.

PLAN MODULE

In this module, various sports plans are installed and showed in for players to
enrol.

iii) ROUTINE MODULE

In this Module, the daily routine for all sports is installed.

2. SYSTEM ANALYSIS

System study is classified into two types

1. Existing system
2. Proposed system

2.1 EXISTING SYSTEM

Here the existing system is nothing but a manual system in which the admin
must fill the member's Sports Club details in an excel sheet and send it to their
supervisor, then the supervisor must merge all the member information details
and arrange them in to a single sheet. Maintaining a clean record of all the
members is a tedious job in this process.
DISADVANTAGES

➤ Paper back records are hard to maintain..

➤ Searching for a member's information can be gruesome task.

➤Doesn't provide Security.

➤ Difficulty in updating the records.

➤ More manual hours is needed to maintain the records.

Updating the member on deadline for payment is difficult.

One way to overcome all these difficulties is so store all the information in
database. The computerization helps mitigate a lot of drawbacks and
streamlines the process.

2.2 PROPOSED SYSTEM

Performance Management System is to replace the existing manual system


with a software solution. It allows all the employees in different sections of the
club to work together and manage a single record.

Different areas of the Sports Club can be managed in different tabs by different
people.

ADVANTAGES

Faster processing

➤ Centralized database helps in avoiding conflicts.

➤ Easy to use GUI that does not require specific training.


3.SYSTEM CONFIGURATION

3.1 HARDWARE SPECIFICATION

Processor

· x86 compatible processor with 1.7 GHz Clock Speed


· Hard disk
· Ram
· 20 GB or greater
· Keyboard
· 512 MB or greater
· Mouse
· 104 Standard keys
· 2/3 button. Optical/Mechanical.

3.2 SOFTWARE SPECIFICATION

Operating Systems

Front End Software

Windows 2000/XP/Vista.

HTML, CSS & BOOTSTRAP

Back End Database

MySQL 8.0

Visual Studio Code 1.56


Aims

The primary aims of the Sports Management System project are to:

Centralize Sports Data: Organize all sports-related information (player data, teams,
schedules, results) into one system for easy management and access.

Simplify Player Management: Allow administrators and coaches to manage player


profiles, including registration, performance, and achievements.

Automate Scheduling and Attendance: Enable efficient scheduling of practices,


matches, and tournaments, and track player attendance and participation.

Monitor Player Performance: Track statistics, performance, and health data, helping
coaches make informed decisions.

Manage Event Results: Maintain records of match and tournament results, which can
be easily accessed for performance analysis.

Database Design Using SQL

Below is the SQL code to create the required tables for the Sports Management System.
The system includes tables for Player, Team, Event, Attendance, and Result.

1. Database Schema and SQL Code:


Create Database

CREATE DATABASE Sports Management;

Switch to the new database

USE Sports Management;

Player Table

CREATE TABLE Player (


player_id INT PRIMARY KEY AUTO_INCREMENT,

first_name VARCHAR(50) NOT NULL,

last_name VARCHAR(50),

age INT,

sport VARCHAR(30),

team_id INT,

contact_number VARCHAR(15),

email VARCHAR(50),

health_data TEXT );

Team Table

CREATE TABLE Team ( team_id INT PRIMARY KEY AUTO_INCREMENT,

team_name VARCHAR(50) NOT NULL,

sport VARCHAR(30),

coach_name VARCHAR(50),

age_group VARCHAR(10 );

Event Table

CREATE TABLE Event

event_id INT PRIMARY KEY AUTO_INCREMENT,

event_name VARCHAR(50) NOT NULL,

event_date DATE,

location VARCHAR(50),

team_id INT,

FOREIGN KEY (team_id) REFERENCES Team(team_id)


);

Attendance Table

CREATE TABLE Attendance (

attendance_id INT PRIMARY KEY AUTO_INCREMENT,

player_id INT,

event_id INT,

attendance_date DATE,

status ENUM('Present', 'Absent') DEFAULT 'Absent',

FOREIGN KEY (player_id) REFERENCES Player(player_id),

FOREIGN KEY (event_id) REFERENCES Event(event_id)

);

Result Table

CREATE TABLE Result (

result_id INT PRIMARY KEY AUTO_INCREMENT,

event_id INT,

team_id INT,

score INT,

position VARCHAR(10),

FOREIGN KEY (event_id) REFERENCES Event(event_id),

FOREIGN KEY (team_id) REFERENCES Team(team_id)

);

2. SQL Code for Sample Data Insertion:

Insert Sample Data into Team


INSERT INTO Team (team_name, sport, coach_name, age_group)

VALUES

('Tigers', 'Basketball', 'Coach Smith', 'Under-16'),

('Lions', 'Football', 'Coach Lee', 'Under-18');

Insert Sample Data into Player

INSERT INTO Player (first_name, last_name, age, sport, team_id,


contact_number, email, health_data)

VALUES

('John', 'Doe', 15, 'Basketball', 1, '1234567890', '[email protected]', 'No


allergies'),

('Jane', 'Smith', 16, 'Football', 2, '0987654321', '[email protected]', 'Asthma');

Insert Sample Data into Event

INSERT INTO Event (event_name, event_date, location, team_id)

VALUES

('City Basketball Championship', '2024-11-15', 'City Arena', 1),

('State Football Match', '2024-12-01', 'State Stadium', 2);

Insert Sample Data into Attendance

INSERT INTO Attendance (player_id, event_id, attendance_date, status)

VALUES

(1, 1, '2024-11-15', 'Present'),

(2, 2, '2024-12-01', 'Absent');

Insert Sample Data into Result

INSERT INTO Result (event_id, team_id, score, position)


VALUES

(1, 1, 78, '1st'),

(2, 2, 54, '2nd');

Expected Output

Players Details
The Player table holds data on each player, including their name, age, team, and
health information. Retrieving data from this table provides an overview of players
registered in the system.

Query Example:

SELECT* FROM Player;

Expected Output:

+-----------+------------+-----------+-----+------------+---------+----------------+-------------
--------+---------------+

| player_id | first_name | last_name | age | sport | team_id | contact_number


| email | health_data |

+-----------+------------+-----------+-----+------------+---------+----------------+-------------
--------+---------------+

|1 | John | Doe | 15 | Basketball | 1 | 1234567890 |


[email protected] | No allergies |

|2 | Jane | Smith | 16 | Football |2 | 0987654321 |


[email protected] | Asthma |

+-----------+------------+-----------+-----+------------+---------+----------------+-------------
--------+---------------+
2.Team Information:

Query Example:

SELECT * FROM Team;

Expected Output:

+---------+-----------+------------+------------+-----------+

| team_id | team_name | sport | coach_name | age_group |

+---------+-----------+------------+------------+-----------+

|1 | Tigers | Basketball | Coach Smith | Under-16 |

|2 | Lions | Football | Coach Lee | Under-18 |

+---------+-----------+------------+------------+-----------+

3.Attendance Status for an Event:

This query provides the attendance status of players for a particular event.

Query Example:

SELECT Player.first_name, Player.last_name, Attendance.status

FROM Attendance

JOIN Player ON Attendance.player_id = Player.player_id

WHERE Attendance.event_id = 1;

Expected Output:

+------------+-----------+---------+

| first_name | last_name | status |


+------------+-----------+---------+

| John | Doe | Present |

+------------+-----------+---------+

4 .Event Results:

Query Example:

SELECT Event.event_name, Team.team_name, Result.score, Result.position

FROM Result

JOIN Event ON Result.event_id = Event.event_id

JOIN Team ON Result.team_id = Team.team_id;

Expected Output:

+----------------------------+-----------+-------+----------+

| event_name | team_name | score | position |

+----------------------------+-----------+-------+----------+

| City Basketball Championship | Tigers | 78 | 1st |

| State Football Match | Lions | 54 | 2nd

);

2. Players Table

Stores player information and links each player to a team.

CREATE TABLE Players (

player_id INT PRIMARY KEY,

player_name VARCHAR(100) NOT NULL,

age INT,
team_id INT,

position VARCHAR(50),

FOREIGN KEY (team_id) REFERENCES Teams(team_id)

);

3. Matches Table

Stores details of matches between two teams.

CREATE TABLE Matches (

match_id INT PRIMARY KEY,

team1_id INT,

team2_id INT,

match_date DATE,

location VARCHAR(100),

FOREIGN KEY (team1_id) REFERENCES Teams(team_id),

FOREIGN KEY (team2_id) REFERENCES Teams(team_id)

4. Scores Table

Stores scores for each match, linked to the Matches table by match ID.

CREATE TABLE Scores (

score_id INT PRIMARY KEY,

match_id INT,

team_id INT,

points INT,

FOREIGN KEY (match_id) REFERENCES Matches(match_id),

FOREIGN KEY (team_id) REFERENCES Teams(team_id)


Example Data Insertion

Add sample data for teams, players, matches, and scores.

-- Insert Teams

INSERT INTO Teams (team_id, team_name, coach_name, city)

VALUES (1, 'Eagles', 'John Doe', 'New York'),

(2, 'Sharks', 'Jane Smith', 'Los Angeles');

-- Insert Players

INSERT INTO Players (player_id, player_name, age, team_id, position)

VALUES (1, 'Alex Johnson', 25, 1, 'Forward'),

(2, 'Chris Lee', 27, 1, 'Goalkeeper'),

(3, 'Sam Brown', 23, 2, 'Defender'),

(4, 'Jamie Green', 24, 2, 'Forward');

-- Insert Matches

INSERT INTO Matches (match_id, team1_id, team2_id, match_date,


location)

VALUES (1, 1, 2, '2024-11-15', 'Stadium A');

-- Insert Scores

INSERT INTO Scores (score_id, match_id, team_id, points)

VALUES (1, 1, 1, 3),

(2, 1, 2, 2);
Example Queries with Output

1. List All Teams

SELECT * FROM Teams;

Expected Output:

team_id team_name coach_name city


1 Eagles John Doe New York
2 Sharks Jane Smith Los Angeles

2. List All Players and Their Teams

SELECT player_name, position, team_name

FROM Players

JOIN Teams ON Players.team_id = Teams.team_id;

Expected Output:

player_name position team_name


Alex Johnson Forward Eagles
Chris Lee Goalkeeper Eagles
Sam Brown Defender Sharks
Jamie Green Forward Sharks

3. Show Match Results

SELECT Matches.match_id, T1.team_name AS team1, T2.team_name


AS team2, Matches.match_date, Scores.team_id, Scores.points

FROM Matches
JOIN Teams T1 ON Matches.team1_id = T1.team_id

JOIN Teams T2 ON Matches.team2_id = T2.team_id

JOIN Scores ON Matches.match_id = Scores.match_id

ORDER BY Matches.match_id, Scores.team_id;

Expected Output:

match_id team1 team2 match_date team_id points


1 Eagles Sharks 2024-11-15 1 3
1 Eagles Sharks 2024-11-15 2 2

4. Retrieve Players by Team

SELECT team_name, player_name

FROM Players

JOIN Teams ON Players.team_id = Teams.team_id

WHERE Teams.team_name = 'Eagles'


Expected Output:

team_name player_name
Eagles Alex Johnson
Eagles Chris Lee

5. Calculate Total Points for Each Team in All Matches

SELECT Teams.team_name, SUM(Scores.points) AS total_points

FROM Scores

JOIN Teams ON Scores.team_id = Teams.team_id

GROUP BY Teams.team_name;
A simple sports management system in SQL could include tables for managing teams,
players, matches, and scores. This setup will allow for the insertion, retrieval, and
updating of records for sports events and player statistics. Below, I’ve provided sample
SQL code with tables, example queries, and expected outputs.

Database Structure

1. Teams Table

Stores team information.


CREATE TABLE Teams ( team_id INT PRIMARY KEY,
team_name VARCHAR(100) NOT NULL, coach_name
VARCHAR(100), city VARCHAR(100) );

2. Players Table

Stores player information and links each player to a team.


CREATE TABLE Players ( player_id INT PRIMARY KEY,
player_name VARCHAR(100) NOT NULL, age INT, team_id
INT, position VARCHAR(50), FOREIGN KEY (team_id)
REFERENCES Teams(team_id) );

3. Matches Table

Stores details of matches between two teams.


CREATE TABLE Matches ( match_id INT PRIMARY KEY,
team1_id INT, team2_id INT, match_date DATE,
location VARCHAR(100), FOREIGN KEY (team1_id)
REFERENCES Teams(team_id), FOREIGN KEY (team2_id)
REFERENCES Teams(team_id) );

4. Scores Table

Stores scores for each match, linked to the Matches table by match ID.

CREATE TABLE Scores ( score_id INT PRIMARY KEY,


match_id INT, team_id INT, points INT, FOREIGN
KEY (match_id) REFERENCES Matches(match_id), FOREIGN
KEY (team_id) REFERENCES Teams(team_id) );

Example Data Insertion

Add sample data for teams, players, matches, and scores.


-- Insert TeamsINSERT INTO Teams (team_id, team_name,
coach_name, city) VALUES (1, 'Eagles', 'John Doe', 'New
York'), (2, 'Sharks', 'Jane Smith', 'Los Angeles');
-- Insert PlayersINSERT INTO Players (player_id,
player_name, age, team_id, position) VALUES (1, 'Alex
Johnson', 25, 1, 'Forward'), (2, 'Chris Lee', 27,
1, 'Goalkeeper'), (3, 'Sam Brown', 23, 2,
'Defender'), (4, 'Jamie Green', 24, 2, 'Forward');
-- Insert MatchesINSERT INTO Matches (match_id, team1_id,
team2_id, match_date, location) VALUES (1, 1, 2, '2024-11-
15', 'Stadium A'); -- Insert ScoresINSERT INTO Scores
(score_id, match_id, team_id, points) VALUES (1, 1, 1, 3),
(2, 1, 2, 2);

Example Queries with Output

1. List All Teams


SELECT * FROM Teams;

Expected Output:

team_id team_name coach_name city


1 Eagles John Doe New York
2 Sharks Jane Smith Los Angeles
2. List All Players and Their Teams
SELECT player_name, position, team_name FROM Players JOIN
Teams ON Players.team_id = Teams.team_id;
Expected Output:

player_name position team_name


Alex Johnson Forward Eagles
Chris Lee Goalkeeper Eagles
Sam Brown Defender Sharks
Jamie Green Forward Sharks
3. Show Match Results
SELECT Matches.match_id, T1.team_name AS team1,
T2.team_name AS team2, Matches.match_date, Scores.team_id,
Scores.points FROM MatchesJOIN Teams T1 ON
Matches.team1_id = T1.team_id JOIN Teams T2 ON
Matches.team2_id = T2.team_id JOIN Scores ON
Matches.match_id = Scores.match_id ORDER BY
Matches.match_id, Scores.team_id;

Expected Output:

match_id team1 team2 match_date team_id points


1 Eagles Sharks 2024-11-15 1 3
1 Eagles Sharks 2024-11-15 2 2
4. Retrieve Players by Team
SELECT team_name, player_name FROM Players JOIN Teams ON
Players.team_id = Teams.team_id WHERE Teams.team_name =
'Eagles';

team_name player_name
Eagles Alex Johnson
Eagles Chris Lee
5. Calculate Total Points for Each Team in All Matches
SELECT Teams.team_name, SUM(Scores.points) AS
total_points FROM Scores JOIN Teams ON Scores.team_id =
Teams.team_id GROUP BY Teams.team_name;

Expected Output:
team_name total_points
Eagles 3
Sharks 2

1. Create the Database Structure

The database structure includes tables for Athletes, Teams, Team_Athletes,


and Games

-- Create the Athletes table

CREATE TABLE Athletes (

athlete_id INT PRIMARY KEY,

name VARCHAR(50),

age INT,

sport VARCHAR(50)

);

-- Create the Teams table

CREATE TABLE Teams (

team_id INT PRIMARY KEY,

team_name VARCHAR(50)

);

-- Create the Team_Athletes table to assign athletes to teams (many-to-many


relationship)

CREATE TABLE Team_Athletes (


team_id INT,

athlete_id INT,

FOREIGN KEY (team_id) REFERENCES Teams(team_id),

FOREIGN KEY (athlete_id) REFERENCES Athletes(athlete_id),

PRIMARY KEY (team_id, athlete_id)

);

-- Create the Games table to record game scores

CREATE TABLE Games (

game_id INT PRIMARY KEY,

team1_id INT,

team2_id INT,

score_team1 INT,

score_team2 INT,

FOREIGN KEY (team1_id) REFERENCES Teams(team_id),

FOREIGN KEY (team2_id) REFERENCES Teams(team_id)

);

2. Insert Sample Data

Insert some sample data for athletes, teams, and a game.

-- Insert sample athletes


INSERT INTO Athletes (athlete_id, name, age, sport) VALUES (1, 'Alice', 23,
'Soccer');

INSERT INTO Athletes (athlete_id, name, age, sport) VALUES (2, 'Bob', 25,
'Soccer');

INSERT INTO Athletes (athlete_id, name, age, sport) VALUES (3, 'Charlie',
21, 'Soccer');

INSERT INTO Athletes (athlete_id, name, age, sport) VALUES (4, 'David', 22,
'Soccer');

-- Insert sample teams

INSERT INTO Teams (team_id, team_name) VALUES (1, 'Sharks');

INSERT INTO Teams (team_id, team_name) VALUES (2, 'Eagles');

-- Assign athletes to teams

INSERT INTO Team_Athletes (team_id, athlete_id) VALUES (1, 1);

INSERT INTO Team_Athletes (team_id, athlete_id) VALUES (1, 2);

INSERT INTO Team_Athletes (team_id, athlete_id) VALUES (2, 3);

INSERT INTO Team_Athletes (team_id, athlete_id) VALUES (2, 4);

-- Record a game between Sharks and Eagles

INSERT INTO Games (game_id, team1_id, team2_id, score_team1,


score_team2) VALUES (1, 1, 2, 2, 3);

3. Retrieve Data
Now that the data is inserted, you can query it.

a. Retrieve team information along with athletes

SELECT t.team_name, a.name AS athlete_name, a.age, a.sport

FROM Teams t

JOIN Team_Athletes ta ON t.team_id = ta.team_id

JOIN Athletes a ON ta.athlete_id = a.athlete_id

ORDER BY t.team_name;

Expected Output:

——————————————————-

team_name | athlete_name | age | sport

——————————————————-

Sharks | Alice | 23 | Soccer

Sharks | Bob | 25 | Soccer

Eagles | Charlie | 21 | Soccer

Eagles | David | 22 | Soccer

b. Retrieve game summary with scores and winner

SELECT g.game_id, t1.team_name AS team1, g.score_team1, t2.team_name


AS team2, g.score_team2,
CASE

WHEN g.score_team1 > g.score_team2 THEN t1.team_name

WHEN g.score_team2 > g.score_team1 THEN t2.team_name

ELSE 'Draw'

END AS winner

FROM Games g

JOIN Teams t1 ON g.team1_id = t1.team_id

JOIN Teams t2 ON g.team2_id = t2.team_id;

Expected Output:

———————————————————————————-

game_id | team1 | score_team1 | team2 | score_team2 | winn

———————————————————————————-

1 | Sharks |2 | Eagles | 3 | Eagles

SQL Code for Creating Tables

-- Creating the Teams table

CREATE TABLE Teams (

team_id INT PRIMARY KEY,

team_name VARCHAR(50) NOT NULL,

coach_name VARCHAR(50),

home_city VARCHAR(50)
);

-- Creating the Players table

CREATE TABLE Players (

player_id INT PRIMARY KEY,

player_name VARCHAR(50) NOT NULL,

age INT,

position VARCHAR(20),

team_id INT,

FOREIGN KEY (team_id) REFERENCES Teams(team_id)

);

-- Creating the Matches table

CREATE TABLE Matches (

match_id INT PRIMARY KEY,

team1_id INT,

team2_id INT,

match_date DATE,

location VARCHAR(50),

FOREIGN KEY (team1_id) REFERENCES Teams(team_id),

FOREIGN KEY (team2_id) REFERENCES Teams(team_id)

);
-- Creating the Scores table

CREATE TABLE Scores (

score_id INT PRIMARY KEY,

match_id INT,

team_id INT,

score INT,

FOREIGN KEY (match_id) REFERENCES Matches(match_id),

FOREIGN KEY (team_id) REFERENCES Teams(team_id)

);

Inserting Sample Data

-- Insert teams

INSERT INTO Teams (team_id, team_name, coach_name, home_city)


VALUES

(1, 'Tigers', 'John Doe', 'New York'),

(2, 'Lions', 'Jane Smith', 'Los Angeles');

-- Insert players

INSERT INTO Players (player_id, player_name, age, position, team_id)


VALUES

(1, 'Alice Brown', 25, 'Forward', 1),

(2, 'Bob White', 22, 'Goalkeeper', 2),


(3, 'Charlie Green', 27, 'Defender', 1),

(4, 'Daisy Blue', 24, 'Midfielder', 2);

-- Insert matches

INSERT INTO Matches (match_id, team1_id, team2_id, match_date, location)


VALUES

(1, 1, 2, '2024-10-15', 'New York Stadium');

-- Insert scores

INSERT INTO Scores (score_id, match_id, team_id, score) VALUES

(1, 1, 1, 3),

(2, 1, 2, 2);

Sample Queries and Output

1. List all Teams

SELECT * FROM Teams;

Output:

——————————————————————

team_id | team_name | coach_name | home_city

——————————————————————

1 | Tigers | John Doe | New York

2 | Lions | Jane Smith | Los Angeles


2. List Players by Team

SELECT player_name, team_name

FROM Players

JOIN Teams ON Players.team_id = Teams.team_id;

Output:

————————————

player_name | team_name

————————————-

Alice Brown | Tigers

Bob White | Lions

Charlie Green | Tigers

Daisy Blue | Lions

3. Show Match Results

SELECT Matches.match_id, team1.team_name AS Team1,


team2.team_name AS Team2, Scores.score

FROM Matches

JOIN Scores ON Matches.match_id = Scores.match_id

JOIN Teams AS team1 ON Matches.team1_id = team1.team_id

JOIN Teams AS team2 ON Matches.team2_id = team2.team_id;

S
Output:

————————————————

match_id | Team1 | Team2 | score

————————————————

1 | Tigers | Lions |3

1 | Tigers | Lions |2

You might also like