Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My Code ( Need step 5 code, Think my step 4 is fine) : * Task 2 Create database */ DROP DATABASE IF EXISTS SOCCER3;



image


My Code( Need step 5 code, Think my step 4 is fine) :

* Task 2 Create database  */
DROP DATABASE IF EXISTS SOCCER3;
CREATE DATABASE SOCCER3;
USE SOCCER3;
SHOW DATABASES;
/* Task 3 Create tables  */
SHOW TABLES;
CREATE TABLE SEASON(
ID INT PRIMARY KEY UNIQUE,
   S_NAME VARCHAR(6) NOT NULL,
   S_YEAR DECIMAL(4,0),
   REGISTRATION_START_DATE DATE,
   REGISTRATION_END_DATE DATE,
   SEASON_START_DATE DATE,
   SEASON_END_DATE DATE);

CREATE TABLE DIVISION (
ID INT PRIMARY KEY UNIQUE,
AGE INT NOT NULL,
SEX CHAR(1) NOT NULL,
D_RANK INT NOT NULL,
EMAIL VARCHAR(30) NOT NULL,
PHONE CHAR(11) NOT NULL,
SEASON_ID INT NOT NULL,
FOREIGN KEY(SEASON_ID) REFERENCES SEASON(ID));

CREATE TABLE CLUB(
ID INT PRIMARY KEY UNIQUE,
C_NAME VARCHAR(23) NOT NULL,
EMAIL_AE VARCHAR(20) NOT NULL,
PHONE CHAR(11) NOT NULL,
ABBREVIATION CHAR(5) UNIQUE);

CREATE TABLE COACH(
 ID INT PRIMARY KEY UNIQUE,
 FIRST_NAME VARCHAR(15) NOT NULL,
 MIDDLE_NAME VARCHAR(15) NULL,
 LAST_NAME VARCHAR(15) NOT NULL,
 DOB DATE NOT NULL,
 STARTING_YEAR DECIMAL(4,0) NOT NULL,
 MOBILE_PHONE CHAR(12) NOT NULL);

CREATE TABLE TEAM(
ID INT PRIMARY KEY UNIQUE,
BIRTH_YEAR DECIMAL(4) NOT NULL,
SEX CHAR(1) NOT NULL,
T_NAME VARCHAR(20) NOT NULL,
EMAIL VARCHAR(20) NOT NULL,
PHONE CHAR(11) NOT NULL,
CLUB_ID INT NOT NULL,
   COACH_ID INT NOT NULL,
   FOREIGN KEY(COACH_ID) REFERENCES COACH(ID),
FOREIGN KEY(CLUB_ID)REFERENCES CLUB(ID));

CREATE TABLE SCHEDULED_GAME(
 CODE CHAR(8) PRIMARY KEY NOT NULL,
 GAME_DATE DATE NOT NULL,
 GAME_TIME TIME NOT NULL,
 LOCATION VARCHAR(60) NOT NULL,
 TEAM_ID INT NOT NULL,
 FOREIGN KEY (TEAM_ID)REFERENCES TEAM(ID));
   
CREATE TABLE ASSIGNMENT(
TEAM_ID INT,
DIVISION_ID INT,
   PRIMARY KEY (TEAM_ID, DIVISION_ID),
   FOREIGN KEY (TEAM_ID) REFERENCES TEAM(ID),
FOREIGN KEY (DIVISION_ID)REFERENCES DIVISION(ID));

CREATE TABLE PLAYER(
ID INT PRIMARY KEY UNIQUE,
   FIRST_NAME VARCHAR(15) NOT NULL,
   MIDDLE_NAME VARCHAR(15) NULL,
   LAST_NAME VARCHAR(15) NOT NULL,
   DOB DATE NOT NULL,
JERSEY_NUMBER INT NOT NULL,
   PARENT_EMAIL VARCHAR(25) NOT NULL,
   TEAM_ID INT NOT NULL,
   FOREIGN KEY (TEAM_ID) REFERENCES TEAM(ID));
   
SHOW TABLES;
DESCRIBE SEASON;
DESCRIBE DIVISION;
DESCRIBE CLUB;
DESCRIBE COACH;
DESCRIBE TEAM;
DESCRIBE SCHEDULED_GAME;
DESCRIBE ASSIGNMENT;
DESCRIBE PLAYER;

/* Task 4 Add data  */
SELECT * FROM SEASON;
SELECT * FROM DIVISION;
SELECT * FROM CLUB;
SELECT * FROM COACH;
SELECT * FROM TEAM;
SELECT * FROM SCHEDULED_GAME;
SELECT * FROM ASSIGNMENT;
SELECT * FROM PLAYER;

INSERT INTO SEASON VALUES
(1, 'Spring', '2020', '2020-08-21', '2020-12-01', '2020-12-06', '2020-02-20'),
   (3, 'Fall', '2021', '2021-07-22', '2021-09-17', '2021-10-19', '2021-12-01'),
   (2, 'Summer', '2019', '2019-03-21', '2019-06-18', '2019-06-20', '2019-09-01'),
   (4, 'Summer', '2020', '2020-07-21', '2020-09-01', '2020-09-04', '2021-02-10'),
   (5, 'Winter', '2021', '2021-12-01', '2021-03-24', '2021-03-26', '2021-06-10');

INSERT INTO DIVISION VALUES
(20, '10', 'M', 1, '..n@.com', '703 2348738', 3),
   (21, '11', 'M', 2, '..e@.com', '703 9304678', 3),
(22, '14', 'F', 3, '..e@.com', '703 8609824', 4),
   (23, '15', 'F', 4, '..r@.com', '703 5678920', 1),
   (24, '16', 'M', 5, '..r@.com', '703 2708904', 2);
   
INSERT INTO CLUB VALUES
(101, 'Frogs', '..s@gmail.com', '703 9834628', 'FROGG'),
(102, 'Whales', '..s@.com', '703 8907625', 'WHALE'),
   (103, 'Tigers', '..s@.com', '703 2709713', 'TIGER'),
   (104, 'Cougars', '..s@.com', '703 9831234', 'COUGS'),
   (105, 'Bulls', '..s@.com', '703 1234575', 'BULLS');

INSERT INTO COACH VALUES
(401, 'Gary', NULL, 'Alan', '1965-04-21', '2020', '703 2707638'),
   (402, 'Ian', NULL, 'Long', '1969-10-14', '2003', '703 8930278'),
   (403, 'Lana', NULL, 'Ram', '1971-05-11', '2020', '703 2349042'),
   (404, 'Valerie', NULL, 'Black', '1970-09-20', '2004', '703 5678912'),
   (405, 'Aaron', NULL, 'Miller', '1968-02-10', '2008', '703 9834672');
   
INSERT INTO TEAM VALUES
(201, '2002', 'M', 'Blue', '..s@.com', '703 9983459', 103, 402),
   (202, '2001', 'F', 'Red', '..s@.com', '703 9981234', 104, 401),
   (203, '2000', 'F', 'Green', '..s@com', '703 9990937', 103, 403),
   (204, '2002', 'F', 'Orange', '..e@.com', '703 9989846', 104, 405),
   (205, '2002', 'M', 'Yellow', '..w@.com', '703 9982951', 102, 404);
   
INSERT INTO SCHEDULED_GAME VALUES
(10000001, '2021-10-01', '08:30:00', 'South Lakes', 205),
   (10000002, '2021-08-20', '10:30:00', 'Herndon ', 201),
   (10000003, '2021-11-22', '08:00:00', 'Mclean', 203),
   (10000004, '2021-02-16', '09:15:00', 'Madison', 204),
   (10000005, '2021-07-10', '012:30:00', 'Chantilly', 202);
   
INSERT INTO ASSIGNMENT VALUES
(203,20),
   (203,23),
   (204,20),
   (204,21),
   (201,20),
   (205,21),
   (202,21),
   (203,21);
   
INSERT INTO PLAYER VALUES
(301, 'Bob', 'Ryan', 'Smith', '2002-08-21', 35, '..a@.com', 204),
   (302, 'Erin', NULL, 'Smith', '2001-03-10', 1, '..y@com', 203),
   (303, 'Alyssa', 'Ann', 'Elliot', '2001-07-22', 16, '..t@com', 201),
   (304, 'Alan', 'Luke', 'Day', '2001-10-03', 35, '..y@.com', 205),
   (305, 'Maren', NULL, 'Sullivan', '2002-05-29', 5, '..y@.com', 202);
   
SELECT * FROM SEASON;
SELECT * FROM DIVISION;
SELECT * FROM CLUB;
SELECT * FROM COACH;
SELECT * FROM TEAM;
SELECT * FROM SCHEDULED_GAME;
SELECT * FROM PLAYER;
SELECT * FROM ASSIGNMENT;

Database Questions for Step 4 Define a current season with the same year as the current year and the same semester as the current semester (fall, spring, summer). Be sure you have at least 2 divisions in the current season, they must have at least 3 teams each, and they must play one game to each other in the current season. The teams must have at least 2 players and a coach. Database Questions for Step 5 For each date (chronologically) compute the number of games. For each club (in alphabetic order) compute the total number of teams playing in the current season. For each division compute the total number of teams enrolled. Sort chronologically. For each coach (in alphabetic order) compute the total numbers of wins.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Databases questions

Question

Explain how to handle criticism well.

Answered: 1 week ago