DBMS: Rules, Entities, Characteristics, Example Tables, Normalization
Verified
Added on  2023/03/30
|32
|2620
|410
AI Summary
This document provides information about the rules of a tennis tournament, entities and relationships in a database management system, characteristics of entities, example tables for the ER model, and normalization to 3rd CNF.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
Running head: DBMS DBMS Name of the Student: Name of the University: Author Note:
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
1DBMS Table of Contents Part 1..........................................................................................................................................2 1. Rules of the business..............................................................................................................2 2. Entities and Relationships......................................................................................................2 3. Characteristics of entities.......................................................................................................3 4. Example Tables for the ER model.........................................................................................5 5. Data Dictionary.....................................................................................................................7 6. Normalization to 3 CNF.........................................................................................................9 Part 2: Project Implementation.................................................................................................12 Queries:....................................................................................................................................29
2DBMS Part 1 1. Rules of the business The VU University is conducting a tennis tournament. It is a knockout tournament where total of 20 teams will participate. Every team will play against each other every round and one winner team will proceed to the next round. There will be a total of four rounds including the final. The team must be consisting of one team leader and rest students. The staff member will be the team leader. A team can have minimum 4 members and maximum 8 members. The organisation needs the team leaders to submit a form two weeks before the tournament start, to register their teams. A single student or staff can only play for one team. The tournament will allow single and pair games. The number if single team games is 4 and number of pair team games is 2. So, a total of 6 games is allotted per team. The total points from all the 6 games are counted against each team and the teams are ranked as per these points. There are a total of 15 referees to monitor the games. Each match is assigned a referee at the start of each round. Each of these referees will be marked against their performances and ranked. The 2ndround will have the 4 highest ranked referees and the 3rdround will have 2 of the highest ranked referees. The final match of the tournament will be refereed by the referee with the highest points. 2. Entities and Relationships The main entities in our relationship are the teams which comprises of the team leaders and team members. The team members are the students and the staff are the team leaders. The staff and the students together constitutes the entity team or in other words, a team cannot exist without the students and the staff. The matches again is another entity which comprises of teams. Teams play in these matches. This entity keep tracks of the points
3DBMS scored by the teams and stores the total scores, fixture details and team names. Hence this entity is derived from the team entity and borrows the team data to work. The Referee is another entity which supervises the match and is connected to the MatchReferee entity which is responsible for keeping the score of the referees. The MatchReferee is also connected to the Matches entity and the Referee entity is responsible for storing the details of the referees. The Student and the staff both entities are connected to the team entity. Many to one relationship is followed in this entity. The Matches entity is totally depended on the team entity. Here one to many relationship is followed as one team can play many matches. The MatchReferee and the Referee entities have many to one relationship as one Referee scorecard sheet can have scores of many referees. The match and the referee entity has one to one relationship as each match can have one referee score for each individual referee. So its relationship between them is on sharing of information to one another basis. 3. Characteristics of entities The main characteristics of the given entities is their attributes, relationships and the primary and foreign keys. a. Student In this entity, the main attributes are student_id, team_id, name, contact_number, email_address and role. The primary key here is the student_id and the foreign key is the team_id. The relationship of this entity with Team is many to one. b. Staff The main attributes of this entity are Staff_id, team_id, name, contact_number, email_address and role. The primary key here is the staff_id and the foreign key here is the team_id. The relationship between the staff and the Team is many to one.
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
4DBMS c. Matches The main attributes of this entity are match_id, first_team_id, second_team_id, winner_team, fixture_date, round, group_name and points. The primary key here is the match_id and the foreign keys are first_team_id, second_team_id and winner_team. The relationship between this entity and the MatchReferee entity is one to one. d. Team The main attributes of this entity are team_id, team_name and team_member. The primary key here is the team_id and there is no foreign key. The relationship between this entity and the Matches are one to many. e. MatchReferee The main attributes of this entity are refree_id, match_id and score. In this entity two attributes are given as both primary and foreign keys and hence can be attributed as two super keys. These super keys are referee_id and match_id. The relationship between this entity and the Referee entity is many to one. f. Referee Themainattributesofthisentityarerefree_id,name,contact_numberand email_address.The primary key here is referee_idand there isno foreign key. The relationship between this entity and the MatchReferee is one to many.
5DBMS 4. Example Tables for the ER model a. Student Student_idTeam_idNameContact_numberEmail_addressRole b. Staff Staff_idTeam_idNameContact_numbeEmail_addressrole
6DBMS r c. Team Team_idTeam_nameTotal_number d. Matches Match _id First_tea m_id Second_tea m_id Winner_t eam Fixture_ date Rou nd Group_n ame poin ts e. MatchReferee Referee_idMatch_idscore f. Referee
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
9DBMS (team_id) second_team_idint11Teamtable (team_id) winner_teamint11Teamtable (team_id) fixture_dateDATE roundvarchar200 group_namevarchar200 pointsint11 Table:Matchreferee AttributeData TypeRangePrimary keyForeign Key referee_idint11YesRefereetable (referee_id) team_idint11Matchtable (match_id) scoreint11 6. Normalization to 3 CNF First Normal Form:The normalization states that database tables must not have any multivalued attributes in order to be in first normal form. The Staff, Student and Team related attributes were in the same table. For each team, the staff and student attributes were multivalued. The table example is provided below. team_idTeam_nameStaff_idStaff_nameStudent_idStudent_name
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
10DBMS 1Blasters1Eden Mead1Alexandra Santo 5CooperDe Loitte 5Luke Glassey 9Nate Heffron If the above table is converted into first normal form then the following table is the answer. team_idTeam_nameStaff_idStaff_nameStudent_idStudent_name 1Blasters1Eden Mead1Alexandra Santo 1Blasters5CooperDe Loitte 5Luke Glassey 1Blasters9Nate Heffron Second Normal Form:The second normal form is the state where database entities are free of partial dependencies. The staff name is dependent on the staff_id and student name is dependent on student id. These two dependencies are partial dependencies. If partial dependencies are resolved then the following tables are created. team_idTeam_nameStaff_idStaff_nameStudent_idStudent_name 1Blasters1Eden Mead1Alexandra Santo 1Blasters5CooperDe5Luke Glassey
11DBMS Loitte 1Blasters9Nate Heffron Staff_idStaff_nameteam_id 1Eden Mead1 5CooperDe Loitte 1 Student_idStudent_nameteam_id 1Alexandra Santo 1 5Luke Glassey1 9Nate Heffron1 team_idTeam_name 1Blasters Third normal form:The database entities are free of transitive dependencies to be in the third normal form. Team_id and referee_id have transitive dependencies among them. That is why a new table called matchreferee is implemented. The matchreferee is consisted of both the math and referee entity primary keys as foreign keys and uses match_id and referee_id as composite primary key.
12DBMS Part 2: Project Implementation DatabaseCreate:CREATEDATABASEIFNOTEXISTS`tenis`DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci; USE `tenis`; Database Development and Data Insert: CREATE TABLE `matches` ( `match_id` int(11) NOT NULL, `first_team_id` int(11) NOT NULL, `second_team_id` int(11) NOT NULL, `winner_team` int(11) DEFAULT NULL, `fixture_date` date NOT NULL, `round` varchar(200) NOT NULL, `group_name` varchar(200) NOT NULL, `points` int(11) DEFAULT NULL ); INSERTINTO`matches`(`match_id`,`first_team_id`,`second_team_id`, `winner_team`, `fixture_date`, `round`, `group_name`, `points`) VALUES (1, 1, 2, NULL, '2019-06-04', 'Round 1', 'Group A', NULL), (2, 1, 3, NULL, '2019-06-05', 'Round 1', 'Group A', NULL), (3, 1, 4, NULL, '2019-06-06', 'Round 1', 'Group A', NULL), (4, 2, 1, NULL, '2019-06-01', 'Round 1', 'Group A', NULL), (5, 2, 3, NULL, '2019-06-02', 'Round 1', 'Group A', NULL), (6, 2, 3, NULL, '2019-06-03', 'Round 1', 'Group A', NULL),
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
21DBMS ALTER TABLE `student` ADD CONSTRAINT `student_ibfk_1` FOREIGN KEY (`team_id`) REFERENCES `team` (`team_id`); COMMIT; Trigger: DELIMITER $$ CREATE TRIGGER `reduce_member2` AFTER DELETE ON `student` FOR EACH ROW begin DECLARE memer_number int; SETmemer_number=(SELECTteam.total_memberfromteamWHERE team.team_id = old.team_id); UPDATE team set team.total_member = (memer_number-1) where team.team_id = old.team_id; END $$ DELIMITER ;
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
22DBMS DELIMITER $$ CREATE TRIGGER `update_team_member2` BEFORE INSERT ON `student` FOR EACH ROW begin DECLARE memer_number int; SETmemer_number=(SELECTteam.total_memberfromteamWHERE team.team_id = new.team_id); UPDATE team set team.total_member = (memer_number+1) where team.team_id = new.team_id; END $$ DELIMITER ;
23DBMS DELIMITER $$ CREATE TRIGGER `reduce_member` AFTER DELETE ON `staff` FOR EACH ROW begin DECLARE memer_number int; SETmemer_number=(SELECTteam.total_memberfromteamWHERE team.team_id = old.team_id); UPDATE team set team.total_member = (memer_number-1) where team.team_id = old.team_id; END $$ DELIMITER ;
24DBMS DELIMITER $$ CREATETRIGGER`update_team_member`AFTERINSERTON`staff`FOR EACH ROW begin DECLARE memer_number int; SETmemer_number=(SELECTteam.total_memberfromteamWHERE team.team_id = new.team_id); UPDATE team set team.total_member = (memer_number+1) where team.team_id = new.team_id; END $$ DELIMITER ; Stored Procedure: DELIMITER $$
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
25DBMS CREATEDEFINER=`root`@`localhost`PROCEDURE`declare_winner`(IN `match_no` INT, IN `team_win` INT, IN `score` INT) BEGIN UPDATE matches Set points = score, winner_team = team_win WHERE match_id = match_no; END$$
26DBMS CREATEDEFINER=`root`@`localhost`PROCEDURE`referee_score`(IN `referee_no` INT, IN `match_no` INT, IN `point` INT) NO SQL BEGIN UPDATE matchreferee Set score = point WHERE match_id = match_no AND referee_id = referee_no; END$$
30DBMS Query 2:SELECT team.team_name, SUM(matches.points) AS TotalScore from team INNERJOINmatchesONteam.team_id=matches.winner_teamGROUPBY team.team_name ORDER BY TotalScore ASC; Query 3:SELECT referee.name, matchreferee.match_id, matchreferee.score FROM referee INNER JOIN matchreferee ON referee.referee_id = matchreferee.referee_id where referee.referee_id =1; Query 4:Select team_name, SUM(TotalScore) As Score From ( SELECT team.team_name, SUM(matches.points) AS TotalScore FROM matches INNER JOIN team on matches.first_team_id = team.team_id GROUP BY team.team_id UNION ALL
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
31DBMS SELECT team.team_name, SUM(matches.points) AS TotalScore FROM matches INNER JOIN team on matches.second_team_id = team.team_id GROUP BY team.team_id)a GROUP BY team_name ORDER BY Score ASC LIMIT 2 Query 5:SELECT student.name AS `Student Name`, staff.name AS `Staff Name`, team_name FROM team INNER JOIN student ON team.team_id = student.team_id INNER JOIN staff ON team.team_id = staff.team_id GROUP BY team_name;