Homework 4 PLAYERS, TEAMS, MATCHES, PENALTIES, COMMITTEE_MEMBERS

Similar documents
Homework 2: Relational Algebra and SQL Due at 5pm on Wednesday, July 20, 2016 NO LATE SUBMISSIONS WILL BE ACCEPTED

Using SQL in MS Access

Online League Management lta.tournamentsoftware.com. User Manual. Further support is available online at

PCSchool - User Guide 2014 Carnival User Guide. Table of Contents

Full-Time People and Registrations Version 5.0

Hot Springs Village Member Portal User Guide

Baseball Nova Scotia Membership Registration Instructions

Player, Coach, Manager, and Team Account Creation

MyCricket User Manual

HOW TO SUBMIT YOUR RACE RESULTS ONLINE?

Player Registration, Transfers & Loan signings

How to enter a scorecard into Play Cricket

McKnight Hockey Association

The ICC Duckworth-Lewis Calculator. Professional Edition 2008

Heart Foundation Walking Website user guide for Walk Organisers

BVIS Beach Volleyball Information System

Registering Club players in Whole Game Club Official Training Guide

2017 Census Reporting To access the SOI s Census Reporting web site go to:

Quick Start Guide. For Gold and Silver Editions

Website User Guide for Walk Organisers

PEACE RIVER SENIOR MEN'S TENNIS LEAGUE

Oracle ebusiness CCTM Supplier: Rate Card

AGW SYSTEMS. Blue Clock W38X

A GUIDE TO THE LOOSE ENDS HOCKEY LEAGUE WEBSITE PAGE

XC2 Client/Server Installation & Configuration

Weet-Bix MyCricket User Manual

Ameren Oracle ebusiness CCTM Supplier

The Game of Yinsh (Phase II)

Database Management Systems. Chapter 5

Lancashire County W.P. & S.A. Age Groups and Championships 2016

Summer Session 2014 Match Results Entry and Verification Instruction Manual

ClubNet System Instructions

Microsoft Windows Software Manual for FITstep Stream Version 4

SCW Web Portal Instructions

Hot Springs Village Member Portal User Guide

Gaia ARI. ARI s Gaia Workshop. Grégory Mantelet. 20 th June 2018 CDS / ARI

Clyne Golf Club Online Booking System Booking

Solution: Homework 2: Relational Algebra Due at 5pm on Monday, February 5, 2018

averun.com Installation Guide

CONTENTS. Welcome to Season Setup in Play Football Setting Up Our Details Setting up Age Groups... 9

MyNetball Club Training Manual

Long Course Level 1 Licensed Open Meet 13 th /14 th January 2018

POLOCROSSE AUSTRALIA NATIONAL DATABASE MANUAL

MyCricket Basics. Season 2016/17. Brett Holliday. Cricket NSW

TECHNICAL NOTE HOW TO USE LOOPERS. Kalipso_TechDocs_Loopers. Revision: 1.0. Kalipso version: Date: 16/02/2017.

Dive Sheets & Running Events Meet Management Software Tutorial for EZMeet Version 3.1 revised 2/4/2006

Prescot SC & Everton SA

Club Set Up for the 2017 Season Setting Up Our Details

GUIDELINE FOR ELECTRONIC REFEREE REPORT. Guideline for Electronic Referee report

Apple Device Instruction Guide- High School Game Center (HSGC) Football Statware

Background Information. Instructions. Problem Statement. HOMEWORK INSTRUCTIONS Homework #4 Pennsylvania Deer Problem

1 Log-in. All Coaches must hand in a Copy of their Risk Management Clearance . Please contact Eastern New York to get a copy. If adding a coach -

Ride for Fun Program. Sponsored by the Douglas County 4-H Horse Association. Program Created by: Cal Pearson, Roland Oswskey & Darlene Oswskey

CLUB REGISTRATION & SUPPORT / TICKETING

2018 Asia Cup-World Ranking Tournament, Stage I Bangkok, March 2-9, 2018

Prescot SC & Everton SA

The ICC Duckworth-Lewis-Stern calculator. DLS Edition 2016

ROTHAMSTED TENNIS CLUB

HAMPSHIRE COUNTY AMATEUR SWIMMING ASSOCIATION SWIMMING CHAMPIONSHIPS CONDITIONS 2017

MyFootballClub Set Up 2018 Club Set Up - Our Details

LiteSpeed for SQL Server 6.5. Integration with TSM

Invitation Letter. President/Secretary General All ISSF Member National Olympic Committee (NOC) All ISSF Archery Members Associations/Federations

ASA North West Region

2-. Allocation of catches aggregates to individual Gear and Species

The Plymouth Network Clubs. Royal Navy Royal Marines. ASA License No: 4SW152221

NOTE: Arlington Soccer has added additional instructions to this guide to assist team registrars

Steltronic StelPad User Guide

Mac Software Manual for FITstep Pro Version 2

OZCHASE RACING - ONLINE NOMINATIONS USER GUIDE - Ozchase Online Nominations User Guide Page 1 of 28

Hertfordshire Girls Football Partnership League Promoting the development of girl s football in Hertfordshire

Fencing Time Version 4.3

Homework Exercises Problem Set 1 (chapter 2)

S.A.S.A North District

Categories: Individuals may score points in three separate competitions: Overall, Age Group, and Age- Graded Formula.

SQL LiteSpeed 3.0 Installation Guide

Petersfield Town Juniors Football Club MANAGERS BRIEFING

USER MANUAL

Three Rivers Golf Members

Equity in Athletics Screening Questions

CORNWALL COUNTY CHESS ASSOCIATION. Constitution

2017 Asia Cup-World Ranking Tournament, Stage II and World Games 2017 Wroclaw Archery Qualification Bangkok, March 19-26, 2017

MAROC Computing Guide for running an event

S.A.S.A North District

Administration and IT Assignment Assessment Task: Sounds on the Shore

FOOTBALL WEST. Sports TG User Guide. Club Administrators

First available date in Term 3

Club Rules and Guidelines. Ashbrook Lawn Tennis Club Bushes Lane, Grosvenor Road (Rear), Rathgar, Dublin 6.

Hazard Training Guide

Creating a New Player and Registering them with the League

GREATER PHILADELPHIA AQUATICS PRESENTS: OKTOBERFEST 2009

... 1 TABLE OF CONTENTS... 2 INTRODUCTION... 3 CREATE TEAMS... 3 COPY TEAMS... 3 ASSIGN PLAYERS AND COACHES Auto-Assignment...

Week 1, Lesson Plan for Success 2. Interactive Notebook 3. HW: Factoring Worksheet. Alg 4 Questionaire.2.docx.

Australian Galloway Association Internet Registrations Recording Registrations Online

LIVERPOOL & DISTRICT SWIMMING & WATER POLO ASSOCIATION Affiliated to the Lancashire County Water Polo & Swimming Association

Parent Guide for Creating Dismissal Exceptions School Year

(Licence no. 3SE161267) At Central Pool, Reading, RG1 7NU 25m, six-lane, electronic timing, antiturbulence

TennisLink Help Guide

GCIT SWIMMING AND THE GLOUCESTER COUNTY SWIM TEAM PARENTS ASSOCIATION PRESENT: OKTOBERFEST 2006

ITF Junior Player Grants Programme Application form

Access will be via the same Player Registration tab via the Player Registrations Officer role section.

Transcription:

Homework 4 In this homework assignment, you will create tennis club database named tennis and write SQL statements to create database tables, load data to the tables, and run MySQL queries. Referential integrity constraints are not considered for this assignment. The tennis database consists of the following tables: PLAYERS, TEAMS, MATCHES, PENALTIES, COMMITTEE_MEMBERS The tennis club database schema is shown in the following Figure. A double-headed arrow at the side of a column (or combination of columns) indicates the primary key of each table based on our UoD (Universe of Discourse). of PLAYERS TEAMNO of TEAMS MATCHNO of MATCHES PAYMENTNO of PENALTIES plus BEGIN_DATE of COMMITTEE_MEMBERS There are several foreign keys as you can see from the schema diagram, but we do not consider referential integrity constraints for creating database tables for this assignment. In the next assignment, we will study how to create database and populate database tables with foreign key constraints. Solution is available on the course web: HW2-Sol.zip The columns in each of the tables are described below. PLAYERS table Unique player number assigned by the club. 1

NAME INITIALS BIRTH_DATE SEX JOINED STREET HOUSENO POSTCODE TOWN PHONENO LEAGUENO Surname of the player, without initials. Initials of the player. No full stops or spaces are used. Date on which the player was born. Sex of the player: M(ale) or F(emale). Year in which the player joined the club. This value cannot be smaller than 1970, the year in which the club was founded. Name of the street on which the player lives. Number of the house. Post code. Town or city in which the player lives. We assume in this example that place names are unique for town or cities or, in other words, there can never be two towns with the same name. Area code followed by a hyphen and then the subscriber's number. League number assigned by the league; a league number is unique. TEAMS table TEAMNO DIVISION Unique team number assigned by the club. Player number of the player who captains the team. In principle, a player may captain several teams. Division in which the league has placed the team. MATCHES table MATCHNO TEAMNO WON LOST Unique match number assigned by the club Number of the team Number of the player Number of sets that the player won in the match Number of sets that the player lost in the match PENALTIES table PAYMENTNO PAYMENT_DATE Unique number for each penalty the club has paid. This number is assigned by the club. Number of the player who has incurred the penalty. Date on which the penalty was paid. The year of this date should not be earlier than 1970, the year in which the club 2

was founded. AMOUNT Amount in dollars incurred for the penalty. COMMITTEE_MEMBERS table BEGIN_DATE END_DATE POSITION The number of the player. Date on which the player became an active member of the committee. This date should not be earlier than January 1, 1990, because this is the date on which the club started to record this data. Date on which the player resigned his position in the committee. This date should not be earlier than the BEGIN_DATE but can be absent. Name of the position. The current database state (data populated) is shown below. The PLAYERS table: NAME INIT BIRTH_DATE SEX JOINED STREET... -------- --------- ---- ---------- --- ------ -------------- --- 2 Everett R 1948-09-01 M 1975 Stoney Road... 6 Parmenter R 1964-06-25 M 1977 Haseltine Lane... 7 Wise GWS 1963-05-11 M 1981 Edgecombe Way... 8 Newcastle B 1962-07-08 F 1980 Station Road... 27 Collins DD 1964-12-28 F 1983 Long Drive... 28 Collins C 1963-06-22 F 1983 Old Main Road... 39 Bishop D 1956-10-29 M 1980 Eaton Square... 44 Baker E 1963-01-09 M 1980 Lewis Street... 57 Brown M 1971-08-17 M 1985 Edgecombe Way... 83 Hope PK 1956-11-11 M 1982 Magdalene Road... 95 Miller P 1963-05-14 M 1972 High Street... 100 Parmenter P 1963-02-28 M 1979 Haseltine Lane... 104 Moorman D 1970-05-10 F 1984 Stout Street... 112 Bailey IP 1963-10-01 F 1984 Vixen Road... The PLAYERS table (continued):... HOUSENO POSTCODE TOWN PHONENO LEAGUENO -------- --- ------- -------- --------- ---------- -------- 2... 43 3575NH Stratford 070-237893 2411 6... 80 1234KK Stratford 070-476537 8467 7... 39 9758VB Stratford 070-347689? 8... 4 6584RO Inglewood 070-458458 2983 27... 804 8457DK Eltham 079-234857 2513 28... 10 1294QK Midhurst 071-659599? 39... 78 9629CD Stratford 070-393435? 44... 23 4444LJ Inglewood 070-368753 1124 57... 16 4377CB Stratford 070-473458 6409 83... 16A 1812UP Stratford 070-353548 1608 3

95... 33A 5746OP Douglas 070-867564? 100... 80 1234KK Stratford 070-494593 6524 104... 65 9437AO Eltham 079-987571 7060 112... 8 6392LK Plymouth 010-548745 1319 The TEAMS table: TEAMNO DIVISION ------ -------- -------- 1 6 first 2 27 second The MATCHES table: MATCHNO TEAMNO WON LOST ------- ------ -------- --- ---- 1 1 6 3 1 2 1 6 2 3 3 1 6 3 0 4 1 44 3 2 5 1 83 0 3 6 1 2 1 3 7 1 57 3 0 8 1 8 0 3 9 2 27 3 2 10 2 104 3 2 11 2 112 2 3 12 2 112 1 3 13 2 8 0 3 The PENALTIES table: PAYMENTNO PAYMENT_DATE AMOUNT --------- -------- ------------ ------ 1 6 1980-12-08 100.00 2 44 1981-05-05 75.00 3 27 1983-09-10 100.00 4 104 1984-12-08 50.00 5 44 1980-12-08 25.00 6 8 1980-12-08 25.00 7 44 1982-12-30 30.00 8 27 1984-11-12 75.00 The COMMITTEE_MEMBERS table: BEGIN_DATE END_DATE POSITION -------- ---------- ---------- -------- 2 1990-01-01 1992-12-31 Chairman 2 1994-01-01? Member 6 1990-01-01 1990-12-31 Secretary 6 1991-01-01 1992-12-31 Member 4

6 1992-01-01 1993-12-31 Treasurer 6 1993-01-01? Chairman 8 1990-01-01 1990-12-31 Treasurer 8 1991-01-01 1991-12-31 Secretary 8 1993-01-01 1993-12-31 Member 8 1994-01-01? Member 27 1990-01-01 1990-12-31 Member 27 1991-01-01 1991-12-31 Treasurer 27 1993-01-01 1993-12-31 Treasurer 57 1992-01-01 1992-12-31 Secretary 95 1994-01-01? Treasurer 112 1992-01-01 1992-12-31 Member 112 1994-01-01? Secretary Step 1: Write createtennisdb.sql which contains the following statements as shown below: source players.sql /* to create players table */ source teams.sql /* to create teams table */ source matches.sql /* to create matches table */ source penalties.sql /* to create penalties table */ source committee_members.sql /* to create committee_members table */ source load_players.sql /* to import data to the table */ source load_teams.sql /* to import data to the table */ source load_matches.sql /* to import data to the table */ source load_penalties.sql /* to import data to the table */ source load_committee_members.sql /* to import data to the table */ In each SQL file for creating a table add drop table if exists table_name SQL statement to delete table if you created before. Step 2: Make data files each of which contains the data to be populated in the target table. You need to have five data files: players.dat, teams.dat, matches.dat, penalties.dat, and committee_members.dat For example, two CSV (comma separated value) data are in teams.dat file. 1, 6, first 2, 27, second Data are imported to two rows in the teams table by load_teams.sql as shown below. load_teams.sql LOAD DATA LOCAL INFILE "teams.dat" INTO TABLE team FIELDS ENCLOSED BY "\"" TERMINATED BY "," ; After logging in to MySQL server, you will need to create new database tennis and select the database for use as shown below. If tennis database exists, delete the database to create a fresh new tennis database. 5

Let us assume your SQL and data files are in the folder /home/mydb (C:\home\myDB). $cd /home/mydb $mysql u <username> -p ----------- Mysql> drop database if exists tennis; mysql> create database `tennis`; /* you do not need to use back tick */ mysql> use tennis; mysql> source createtennisdb.sql //In Linux, you need to open MySQL command shell in //order to bypass security problem caused by bulk loading using infile //$mysql -local-infile u accountname p //Passwd: enter password //source source.sql Step 3: Write SQL statements which perform the following tasks. 1. Get the numbers, names, and initials of all players whose name and initials are equal to that of the player 6 or of the player 27. 2. Find the names and initials of players for whom at least one penalty has been paid. 3. Get the names and initials of the players who are not team captains. 4. Get the number and name of each player who has incurred at least one penalty. 5. Get all the different town names from the PLAYERS table. 6. For each town, find the number of players. 7. For each team, get the team number, the number of matches that has been played for that team, and the total number of sets won. 8. For each team that is captained by a player resident in Eltham, get the team number and the number of matches that has been played for that team. 9. Get each different penalty amount, followed by the number of times that the amount occurs, in the PENALTIES table, and also show the result of that amount multiplied by the number. 10. For the MATCHES table, get all the different combinations of team numbers and player numbers. 11. For each player who has ever incurred at least one penalty, get the player number, the name, and the total amount in penalties incurred. 12. Get the player number of each player whose last penalty was incurred in 1984. 13. For each player who has incurred more than $150 worth of penalties in total, find the player number and the total amount of penalties. 14. For each player who is a captain and who has incurred more than $80 worth of penalties in total, find the player number and the total amount of penalties. 15. Get the player number and the total amount of penalties for the player with the highest penalty total. 16. For each match, get the player number, team number, and difference between the number of sets won and the number of sets lost; order the result in ascending order on the difference. 6