{"id":22967824,"url":"https://github.com/ibensusan/tournament-database-project","last_synced_at":"2025-06-14T22:40:10.499Z","repository":{"id":258259313,"uuid":"867051418","full_name":"iBensusan/Tournament-Database-Project","owner":"iBensusan","description":"Database create for a multi-sport tournament built using SQL and PL/SQL, the system is optimised for data retrieval and performance.","archived":false,"fork":false,"pushed_at":"2024-10-03T11:28:36.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T05:19:18.679Z","etag":null,"topics":["database","sql","sql-query"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iBensusan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-03T11:14:11.000Z","updated_at":"2024-10-10T09:31:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"0acf85da-1faa-49a2-b745-748183137bce","html_url":"https://github.com/iBensusan/Tournament-Database-Project","commit_stats":null,"previous_names":["ibensusan/tournament-database-project"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iBensusan/Tournament-Database-Project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iBensusan%2FTournament-Database-Project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iBensusan%2FTournament-Database-Project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iBensusan%2FTournament-Database-Project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iBensusan%2FTournament-Database-Project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iBensusan","download_url":"https://codeload.github.com/iBensusan/Tournament-Database-Project/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iBensusan%2FTournament-Database-Project/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259894445,"owners_count":22928202,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","sql","sql-query"],"created_at":"2024-12-14T21:14:53.487Z","updated_at":"2025-06-14T22:40:10.455Z","avatar_url":"https://github.com/iBensusan.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tournament Database Project\n\n## Objective\nThe goal of this project is to design, implement, and demonstrate a database system for a multi-sport tournament, supporting different sports (Football, Basketball, Tennis). The database includes tables for storing tournament data, teams, players, and their performances, as well as complex functionalities like views, stored procedures, and triggers to manage and process the tournament data efficiently.\n\n## Project Overview\nThis project simulates a sports tournament database, which includes multiple sports and teams. It covers the creation of tables, insertion of sample data, and implementation of PL/SQL functionalities, such as views, stored procedures, and triggers, to handle specific operations like calculating player statistics and generating tournament schedules.\n\n## Database Design\nThe database is structured with both normalized and denormalized tables for optimized data retrieval and performance. The design follows the principles of normalization, but strategic denormalization is applied to avoid complex joins and improve query performance.\n\n### Key Components:\n- **Tournament Table**: Stores information about tournaments, including name and duration.\n- **Team and Player Tables**: Represent teams and players participating in various sports.\n- **PlayerStatistics and TeamStatistics**: Track performance metrics like goals, assists, sets won, and more.\n- **Sports-Specific Tables**: Each sport (Football, Basketball, Tennis) has a dedicated table for its specific data attributes.\n\n## SQL and PL/SQL Implementation\n\n### 1. Table Creation\nThe database includes several tables that store data about tournaments, teams, players, and their statistics. Each table is created using SQL, and all necessary primary and foreign keys are included for data integrity.\n\nExample of table creation:\n\nCREATE TABLE Tournament (\n    Tournament_ID Float(10) Not Null,\n    Tournament_name Varchar(20) Not Null,\n    Start_date Date Not NUll,\n    End_date Date Not Null,\n    Primary key (Tournament_ID)\n);\n\n\n### 2. Data Insertion\nSample data is inserted into the tables to populate the database. The \\`INSERT ALL INTO\\` query is used for inserting multiple rows at once for efficiency.\n\nExample data insertion:\n\nINSERT ALL\nINTO TournamentSport (Tournament_IDSport_ID) VALUES ('0001''01')\nINTO TournamentSport (Tournament_IDSport_ID) VALUES ('0001''02')\nINTO TournamentSport (Tournament_IDSport_ID) VALUES ('0001''03')\nSELECT * FROM dual;\n\n\n### 3. Views\nViews are created to simplify complex queries by combining data from multiple tables. These views present meaningful information to the user, such as schedules and player performance.\n\nExample view:\n\nCREATE VIEW TournamentScheduleView AS\nSELECT t.Tournament_Name, s.Sport_Name, sch.Venue, sch.Date_Time\nFROM Tournament t\nJOIN Schedule sch ON t.Tournament_ID = sch.Tournament_ID\nJOIN Sport s ON s.Sport_ID = sch.Sport_ID;\n\n\n### 4. Stored Procedures\nStored procedures are implemented to automate processes like calculating player statistics or generating team schedules. These procedures take input parameters and perform updates or insertions into the database based on complex logic.\n\nExample procedure:\n\nCREATE OR REPLACE PROCEDURE CalculatePlayerStatistics(\n  p_player_id IN PlayerStatistics.Player_ID%TYPE,\n  p_sport_id IN PlayerStatistics.Sport_ID%TYPE\n) AS\nBEGIN\n  UPDATE PlayerStatistics\n  SET Goal_Scored = (SELECT SUM(Score) FROM Game WHERE Team_ID IN (SELECT Team_ID FROM Team WHERE Sport_ID = p_sport_id) AND Player_ID = p_player_id),\n      Points_Scored = (SELECT SUM(Score) FROM Game WHERE Team_ID IN (SELECT Team_ID FROM Team WHERE Sport_ID = p_sport_id) AND Player_ID = p_player_id),\n      Assist = (SELECT COUNT(*) FROM Game WHERE Team_ID IN (SELECT Team_ID FROM Team WHERE Sport_ID = p_sport_id) AND Player_ID = p_player_id)\n  WHERE Player_ID = p_player_id AND Sport_ID = p_sport_id;\n  COMMIT;\nEND;\n\n\n### 5. Triggers\nTriggers are used to automatically update player statistics whenever a new game is recorded. This ensures that the data remains consistent and up-to-date without manual intervention.\n\nExample trigger:\n\nCREATE OR REPLACE TRIGGER UpdatePlayerStatisticsTrigger\nAFTER INSERT ON Game\nFOR EACH ROW\nBEGIN\n  UPDATE PlayerStatistics\n  SET Goal_Scored = Goal_Scored + :NEW.Score,\n      Points_Scored = Points_Scored + :NEW.Score,\n      Sets_Won = Sets_Won + :NEW.Score,\n      Assist = Assist + :NEW.Assist\n  WHERE Player_ID = :NEW.Player_ID AND Sport_ID = :NEW.Sport_ID;\nEND;\n\n\n## How to Run the Project\n1. Clone this repository to your local machine.\n2. Set up your database (Oracle, MySQL, etc.) and create the tables as outlined in the SQL scripts.\n3. Insert the sample data provided.\n4. Use the provided stored procedures and triggers for various database operations.\n\n## Conclusion\nThis project showcases a comprehensive database system for managing a multi-sport tournament. It uses a combination of table structures, views, procedures, and triggers to offer a robust and efficient solution for handling tournament-related data.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibensusan%2Ftournament-database-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fibensusan%2Ftournament-database-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibensusan%2Ftournament-database-project/lists"}