0% found this document useful (0 votes)
9 views9 pages

Sports Management System Project

The document outlines a Class 12 Computer Science project titled 'Sports Management System', developed using Python and MySQL. It includes details on the project's objectives, database schema, Python code for CRUD operations, and instructions for running the project. Additionally, it suggests future enhancements and provides a structure for the project report.

Uploaded by

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

Sports Management System Project

The document outlines a Class 12 Computer Science project titled 'Sports Management System', developed using Python and MySQL. It includes details on the project's objectives, database schema, Python code for CRUD operations, and instructions for running the project. Additionally, it suggests future enhancements and provides a structure for the project report.

Uploaded by

kajalpatel9056
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Computer science project ...

Class
12th
# Sports Management System

**Class:** 12th Computer Science


**Project Title:** Sports Management System (Python + MySQL)
**Student Name:** _________________
**Roll No.:** _________________
**School:** _________________
**Submitted To:** _________________

---

## Certificate

This is to certify that the project entitled **"Sports Management


System"** submitted by **_________________** in partial fulfillment
of the requirements for the Class 12 Computer Science
examination is an original work carried out by the student under
my supervision.

**Guide (Teacher):** ____________________


**Signature:** ____________________
**Date:** ____________________

---

## Acknowledgement

I express my sincere gratitude to my teacher and guide


**(Name)** for their valuable guidance and encouragement. I
would also like to thank my parents and friends for their support
during the completion of this project.

---

## Abstract

The Sports Management System is a simple database-driven


application developed using **MySQL** for data storage and
**Python** for the user interface and logic. The system helps
manage coaches, teams, players, and events. It supports basic
operations such as **Create, Read, Update, Delete (CRUD)** and
helps demonstrate how databases interact with Python programs.

---

## Objectives

* To design and implement a relational database for sports


management.
* To connect Python with MySQL and perform CRUD operations.
* To demonstrate data integrity using foreign keys and
constraints.
* To provide a simple, menu-driven interface for users.

---

## Tools and Technologies

* **MySQL** (or MariaDB)


* **Python 3.x**
* Python package: `mysql-connector-python`
* Optional GUI: `tkinter` (not included in the basic version)

---

## ER Diagram (Textual)

```
Coaches (coach_id PK) 1 --- * Teams (team_id PK, coach_id FK)
Teams (team_id PK) 1 --- * Players (player_id PK, team_id FK)

Entities:
- Coaches: coach_id, coach_name, experience
- Teams: team_id, team_name, coach_id
- Players: player_id, name, age, sport, team_id
```

---

## Database Schema (MySQL)


```sql
-- 1. Create Database
CREATE DATABASE IF NOT EXISTS sports_management;
USE sports_management;

-- 2. Coaches Table
CREATE TABLE IF NOT EXISTS Coaches (
coach_id INT PRIMARY KEY AUTO_INCREMENT,
coach_name VARCHAR(100) NOT NULL,
experience INT
);

-- 3. Teams Table
CREATE TABLE IF NOT EXISTS Teams (
team_id INT PRIMARY KEY AUTO_INCREMENT,
team_name VARCHAR(100) NOT NULL,
coach_id INT,
FOREIGN KEY (coach_id) REFERENCES Coaches(coach_id)
ON DELETE SET NULL
ON UPDATE CASCADE
);

-- 4. Players Table
CREATE TABLE IF NOT EXISTS Players (
player_id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
age INT,
sport VARCHAR(50),
team_id INT,
FOREIGN KEY (team_id) REFERENCES Teams(team_id)
ON DELETE SET NULL
ON UPDATE CASCADE
);
```

Notes:

* `ON DELETE SET NULL` is used so that if a Coach/Team is


removed, related rows set team/coach to NULL instead of deleting
players/teams.
---

## Sample Data (Insert Statements)

```sql
INSERT INTO Coaches (coach_name, experience) VALUES
('Rahul Sharma', 10),
('Anil Mehra', 8);

INSERT INTO Teams (team_name, coach_id) VALUES


('Warriors', 1),
('Strikers', 2);

INSERT INTO Players (name, age, sport, team_id) VALUES


('Amit Kumar', 20, 'Cricket', 1),
('Rohan Singh', 18, 'Football', 2),
('Sneha Patel', 19, 'Badminton', NULL);
```

---

## Python Program (Console-based)

> Save this file as `sports_management.py`

```python
import [Link]
from [Link] import Error

DB_CONFIG = {
'host': 'localhost',
'user': 'root',
'password': 'yourpassword',
'database': 'sports_management'
}

# Utility: connect to database


def get_connection():
try:
conn = [Link](**DB_CONFIG)
return conn
except Error as e:
print('Error connecting to MySQL:', e)
return None

# Create functions for CRUD operations

def add_coach():
name = input('Coach name: ').strip()
exp = input('Experience (years): ').strip()
conn = get_connection()
if conn:
cur = [Link]()
[Link]('INSERT INTO Coaches (coach_name, experience)
VALUES (%s, %s)', (name, exp or None))
[Link]()
print('Coach added.')
[Link](); [Link]()

def view_coaches():
conn = get_connection()
if conn:
cur = [Link]()
[Link]('SELECT * FROM Coaches')
rows = [Link]()
for r in rows:
print(r)
[Link](); [Link]()

def add_team():
name = input('Team name: ').strip()
coach_id = input('Coach ID (leave blank if none): ').strip() or
None
conn = get_connection()
if conn:
cur = [Link]()
[Link]('INSERT INTO Teams (team_name, coach_id)
VALUES (%s, %s)', (name, coach_id))
[Link]()
print('Team added.')
[Link](); [Link]()

def view_teams():
conn = get_connection()
if conn:
cur = [Link]()
[Link]('SELECT t.team_id, t.team_name, c.coach_name
FROM Teams t LEFT JOIN Coaches c ON t.coach_id = c.coach_id')
for row in [Link]():
print(row)
[Link](); [Link]()

def add_player():
name = input('Player name: ').strip()
age = input('Age: ').strip() or None
sport = input('Sport: ').strip() or None
team_id = input('Team ID (leave blank if none): ').strip() or
None
conn = get_connection()
if conn:
cur = [Link]()
[Link]('INSERT INTO Players (name, age, sport,
team_id) VALUES (%s, %s, %s, %s)', (name, age, sport, team_id))
[Link]()
print('Player added.')
[Link](); [Link]()

def view_players():
conn = get_connection()
if conn:
cur = [Link]()
[Link]('SELECT p.player_id, [Link], [Link], [Link],
t.team_name FROM Players p LEFT JOIN Teams t ON p.team_id =
t.team_id')
for row in [Link]():
print(row)
[Link](); [Link]()
def main_menu():
while True:
print('\n--- SPORTS MANAGEMENT MENU ---')
print('1. Add Coach')
print('2. View Coaches')
print('3. Add Team')
print('4. View Teams')
print('5. Add Player')
print('6. View Players')
print('7. Exit')
choice = input('Choice: ').strip()
if choice == '1': add_coach()
elif choice == '2': view_coaches()
elif choice == '3': add_team()
elif choice == '4': view_teams()
elif choice == '5': add_player()
elif choice == '6': view_players()
elif choice == '7':
print('Goodbye!')
break
else:
print('Invalid choice')

if __name__ == '__main__':
main_menu()
```

---

## How to Run the Project (Step-by-step)

1. Install MySQL server and create the `sports_management`


database.
2. Run the MySQL schema SQL (create tables) in MySQL
Workbench or phpMyAdmin.
3. (Optional) Insert sample data using the provided INSERT
statements.
4. Install Python 3.x. Install connector:

```bash
pip install mysql-connector-python
```

5. Update `DB_CONFIG` in the Python file with your MySQL


username and password.
6. Run the Python program:

```bash
python sports_management.py
```

7. Use the menu to add/view coaches, teams, players.

---

## Output Screens (Example)

When you run `view_players()`, you may see rows like:

```
(1, 'Amit Kumar', 20, 'Cricket', 'Warriors')
(2, 'Rohan Singh', 18, 'Football', 'Strikers')
```

---

## Project Report (What to write in the file)

* Title page and certificate (provided above)


* Acknowledgement
* Abstract
* Introduction and Tools used
* ER Diagram and Schema
* SQL code (create + sample data)
* Python code (with explanations)
* Screenshots of running the program (take yourself)
* Conclusion and Future Scope

---

## Conclusion
This Sports Management System is a simple, functional project
demonstrating the use of relational databases with Python. It is
suitable for Class 12 Computer Science practical and report
submission.

---

## Future Enhancements (Ideas)

* Add an authentication system (admin login)


* Add a GUI using `tkinter` or `PyQt`
* Add Matches/Events table with scheduling
* Export reports to CSV or PDF

---

## References

* Official MySQL Documentation


* `mysql-connector-python` documentation
* Python 3 documentation

---

*End of document*

Common questions

Powered by AI

Improving data security in the Sports Management System could involve implementing several techniques such as adding user authentication and role-based access controls to ensure that only authorized users can perform certain operations. Additionally, incorporating data validation checks to prevent SQL injection and encrypting sensitive data might be critical. Logging and monitoring to track changes and access patterns, alongside regular security audits, could further enhance security and reduce vulnerabilities .

The Sports Management System ensures data integrity by using foreign keys and constraints in its database schema. For instance, it establishes relations between tables like setting 'coach_id' as a foreign key in the 'Teams' table referencing the 'Coaches' table. Similarly, 'team_id' in the 'Players' table references the 'Teams' table. These connections help maintain referential integrity, preventing orphan records and ensuring that updates on primary keys cascade to dependent tables .

The interaction between Python and MySQL in the Sports Management System project is facilitated using the Python package `mysql-connector-python`. This package allows Python scripts to execute SQL queries, connect to the MySQL database, and perform CRUD operations seamlessly. The project includes utility functions to establish database connections and multiple functions to handle database transactions through SQL .

CRUD operations in the Sports Management System represent core functionalities that manage data within the database. Strengths of this approach include its simplicity, the ability to systematically manage data through standard operations, and its foundational role in database management systems. However, limitations may arise in handling complex transactions or operations that require transaction management beyond simple CRUD. Moreover, without additional security measures and validation, CRUD operations could pose risks of data manipulation errors or accidental deletions .

The entity-relationship (ER) diagram plays a crucial role in the Sports Management System as it lays out the data model and relationships between different entities such as Coaches, Teams, and Players. It helps in visualizing how data is structured and interconnected, guiding the creation of a normalized database schema. This ensures efficient data storage, retrieval, and integrity, directly impacting the project's development by providing a clear blueprint for database architecture .

The ER diagram in the Sports Management System indicates a one-to-many relationship between coaches and teams, wherein one coach can manage multiple teams. This is represented by the coach_id being a foreign key in the Teams table, linking back to the Coaches table, thereby allowing each team to associate with a single coach while enabling a coach to oversee several teams. This relationship model promotes structured data organization and hierarchical management roles .

The primary objectives of the Sports Management System project are to design and implement a relational database for sports management, connect Python with MySQL to perform CRUD operations, demonstrate data integrity using foreign keys and constraints, and provide a simple, menu-driven interface for users .

Using 'ON DELETE SET NULL' in foreign key constraints within the Sports Management System database is significant as it helps maintain data integrity without losing crucial data relationships. For instance, when a coach or team is deleted, associated players or teams are not removed but their references set to NULL. This approach prevents the accidental deletion of related entries while allowing database administrators to handle orphan records in a controlled manner .

The document suggests several potential future enhancements for the Sports Management System: adding an authentication system with admin login, developing a GUI using `tkinter` or `PyQt`, incorporating a Matches/Events table with scheduling capabilities, and enabling the export of reports to CSV or PDF formats .

Implementing a GUI in the Sports Management System could enhance user interaction by providing a more intuitive and visually appealing interface. A GUI would allow users to navigate through options, enter data, and view records more easily compared to a purely console-based system. Using tools like `tkinter` or `PyQt` could improve accessibility, offer better error handling, and reduce the learning curve for users less familiar with command-line operations, thereby broadening the software's usability .

You might also like