basketball league database schema
- User
basketball league database schema
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
basketball league database schema
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Designing a database schema for a basketball league involves capturing all the necessary entities, their attributes, and the relationships between them. Below is a detailed database schema for a basketball league, represented in a relational database format. This schema includes tables for teams, players, games, statistics, and more. I'll also provide explanations for each table and its purpose.
This table stores information about the teams in the league.
| Column Name | Data Type | Constraints | Description |
|---|---|---|---|
| team_id | INT | PRIMARY KEY | Unique identifier for each team |
| team_name | VARCHAR(100) | NOT NULL | Name of the team |
| city | VARCHAR(100) | NOT NULL | City the team is based in |
| coach_name | VARCHAR(100) | NOT NULL | Name of the team's coach |
| founded_year | INT | Year the team was founded |
This table stores information about the players in the league.
| Column Name | Data Type | Constraints | Description |
|---|---|---|---|
| player_id | INT | PRIMARY KEY | Unique identifier for each player |
| first_name | VARCHAR(50) | NOT NULL | Player's first name |
| last_name | VARCHAR(50) | NOT NULL | Player's last name |
| team_id | INT | FOREIGN KEY | References Teams(team_id) |
| position | VARCHAR(20) | NOT NULL | Player's position (e.g., PG, SG, SF, PF, C) |
| jersey_number | INT | NOT NULL | Player's jersey number |
| date_of_birth | DATE | NOT NULL | Player's date of birth |
| height_cm | INT | NOT NULL | Player's height in centimeters |
| weight_kg | INT | NOT NULL | Player's weight in kilograms |
This table stores information about the games played in the league.
| Column Name | Data Type | Constraints | Description |
|---|---|---|---|
| game_id | INT | PRIMARY KEY | Unique identifier for each game |
| home_team_id | INT | FOREIGN KEY | References Teams(team_id) |
| away_team_id | INT | FOREIGN KEY | References Teams(team_id) |
| game_date | DATE | NOT NULL | Date of the game |
| game_time | TIME | NOT NULL | Start time of the game |
| venue | VARCHAR(100) | NOT NULL | Venue where the game is played |
| home_team_score | INT | Final score of the home team | |
| away_team_score | INT | Final score of the away team | |
| season | VARCHAR(10) | NOT NULL | Season (e.g., "2023-2024") |
This table stores individual player statistics for each game.
| Column Name | Data Type | Constraints | Description |
|---|---|---|---|
| stat_id | INT | PRIMARY KEY | Unique identifier for each stat record |
| game_id | INT | FOREIGN KEY | References Games(game_id) |
| player_id | INT | FOREIGN KEY | References Players(player_id) |
| minutes_played | INT | NOT NULL | Minutes played by the player |
| points | INT | NOT NULL | Points scored by the player |
| rebounds | INT | NOT NULL | Total rebounds |
| assists | INT | NOT NULL | Total assists |
| steals | INT | NOT NULL | Total steals |
| blocks | INT | NOT NULL | Total blocks |
| turnovers | INT | NOT NULL | Total turnovers |
| field_goals_made | INT | NOT NULL | Field goals made |
| field_goals_attempted | INT | NOT NULL | Field goals attempted |
| three_points_made | INT | NOT NULL | Three-point shots made |
| three_points_attempted | INT | NOT NULL | Three-point shots attempted |
| free_throws_made | INT | NOT NULL | Free throws made |
| free_throws_attempted | INT | NOT NULL | Free throws attempted |
This table stores information about the seasons in the league.
| Column Name | Data Type | Constraints | Description |
|---|---|---|---|
| season_id | INT | PRIMARY KEY | Unique identifier for each season |
| season_name | VARCHAR(10) | NOT NULL | Season name (e.g., "2023-2024") |
| start_date | DATE | NOT NULL | Start date of the season |
| end_date | DATE | NOT NULL | End date of the season |
This table tracks the performance of teams during a season.
| Column Name | Data Type | Constraints | Description |
|---|---|---|---|
| standing_id | INT | PRIMARY KEY | Unique identifier for each standing record |
| season_id | INT | FOREIGN KEY | References Seasons(season_id) |
| team_id | INT | FOREIGN KEY | References Teams(team_id) |
| wins | INT | NOT NULL | Number of wins |
| losses | INT | NOT NULL | Number of losses |
| win_percentage | DECIMAL(5,3) | NOT NULL | Win percentage (e.g., 0.750) |
| games_played | INT | NOT NULL | Total games played |
This table stores information about the coaches in the league (optional, if you want to track coach history).
| Column Name | Data Type | Constraints | Description |
|---|---|---|---|
| coach_id | INT | PRIMARY KEY | Unique identifier for each coach |
| first_name | VARCHAR(50) | NOT NULL | Coach's first name |
| last_name | VARCHAR(50) | NOT NULL | Coach's last name |
| date_of_birth | DATE | NOT NULL | Coach's date of birth |
| years_experience | INT | NOT NULL | Years of coaching experience |
This table tracks the history of coaches for each team (optional, if you want to track changes in coaching staff).
| Column Name | Data Type | Constraints | Description |
|---|---|---|---|
| history_id | INT | PRIMARY KEY | Unique identifier for each record |
| team_id | INT | FOREIGN KEY | References Teams(team_id) |
| coach_id | INT | FOREIGN KEY | References Coaches(coach_id) |
| start_date | DATE | NOT NULL | Start date of the coach's tenure |
| end_date | DATE | End date of the coach's tenure (NULL if current) |
This table tracks player injuries (optional, if you want to track player availability).
| Column Name | Data Type | Constraints | Description |
|---|---|---|---|
| injury_id | INT | PRIMARY KEY | Unique identifier for each injury |
| player_id | INT | FOREIGN KEY | References Players(player_id) |
| injury_type | VARCHAR(100) | NOT NULL | Type of injury (e.g., "Sprained Ankle") |
| start_date | DATE | NOT NULL | Date the injury occurred |
| end_date | DATE | Date the player recovered (NULL if ongoing) |
Here’s a summary of the relationships between the tables:
Here’s an example of how you might create the Teams, Players, and Games tables in SQL:
-- Create Teams table
CREATE TABLE Teams (
team_id INT PRIMARY KEY AUTO_INCREMENT,
team_name VARCHAR(100) NOT NULL,
city VARCHAR(100) NOT NULL,
coach_name VARCHAR(100) NOT NULL,
founded_year INT
);
-- Create Players table
CREATE TABLE Players (
player_id INT PRIMARY KEY AUTO_INCREMENT,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
team_id INT,
position VARCHAR(20) NOT NULL,
jersey_number INT NOT NULL,
date_of_birth DATE NOT NULL,
height_cm INT NOT NULL,
weight_kg INT NOT NULL,
FOREIGN KEY (team_id) REFERENCES Teams(team_id)
);
-- Create Games table
CREATE TABLE Games (
game_id INT PRIMARY KEY AUTO_INCREMENT,
home_team_id INT,
away_team_id INT,
game_date DATE NOT NULL,
game_time TIME NOT NULL,
venue VARCHAR(100) NOT NULL,
home_team_score INT,
away_team_score INT,
season VARCHAR(10) NOT NULL,
FOREIGN KEY (home_team_id) REFERENCES Teams(team_id),
FOREIGN KEY (away_team_id) REFERENCES Teams(team_id)
);
Leagues table and link it to Teams and Seasons.Coaches, Team_Coach_History, and Injuries are optional and can be included based on your specific requirements.game_date, player_id, team_id).VARCHAR lengths) based on your specific needs and database system (MySQL, PostgreSQL, etc.).Let me know if you need further clarification or additional features!