Question

Q.1] Write SQL statements based on the tennis database schema (practice homework 5) Get all the different town names from the


In this homework assignment, you will create tennis club database named tennis and write SQ statements to create database t
Q.1] Write SQL statements based on the tennis database schema (practice homework 5) Get all the different town names from the PLAYERS table. 2. For each town, find the number of players. 3. 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. 4. For each team that is captained by a player resident in "Eltham", get the team number and the number of matches that has been plaved for that team 1.
In this homework assignment, you will create tennis club database named "tennis" and write SQ 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. PENALTIES table PLAYERS table TEAMS table PAYMENTNO PLAYERNO PLAYERNO NAME PLAYERNO PAYMENT DATE INITIALS DIVISION AMOUNT BIRTH DATE (NULL) SEX JOINED STREET MATCHES table COMMITTEE MEMBER table HOUSENO (NULL) MATCHNGO PLAYERNO POSTCODE (NULL) TEAMNO BEGIN DATE TOWN PLAYERNO END DATE (NULL) PHONENO (NULL) WON POSITION (NULL) LEAGUENO (NULL) LOST 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). PLAYERNO of PLAYERS TEAMNO of TEAMS MATCHNO of MATCHES PAYMENTNO of PENALTIES PLAYERNO 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.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

--1 Distinct is key word helps to get unique records.

Select Distinct Town From Players;

--2 Group by helps to get num of players for each town.

Select Town,count(PlayerNo) As NumPlayer from Players Group by Town;

--3

Select teamno,count(matchno),sum(won) As SetsWon From Matches Group by teamno;

in above query im im assuming Won column will have num of sets match won. If no sets won then it will be zero.

--4

select teamNo,Count(MatchNo) As NumMatches From Matches Group by TeamNo Having PlayerNo IN (select playerno from players where town='Eltham' and playerno in (select playerno from commitee_member where position='captain'));

Using multiple subquery we are filtering data.

Add a comment
Know the answer?
Add Answer to:
Q.1] Write SQL statements based on the tennis database schema (practice homework 5) Get all the different tow...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (SQL) Write DDL statements to create the tables below and use appropriate data types for the...

    (SQL) Write DDL statements to create the tables below and use appropriate data types for the attributes.Relational database schema: Teacher = [CourseN, Quarter,TeacherName] Course = [CourseN,CourseName, Nunit) LocationNTime = [CourseN, Quarter , DayTime, RoomN] . //Examples of DayTime: M2:00AM, W4:50PM, and T8:00PM. Note that DayTime is represented as a string. Student = [studentName, CourseN, Quarter] .................... The DDL statement must include at least the following constraints: Every Primary Key; Every Foreign Key; For every Foreign Key constraint, the referential integrity...

  • QUESTION 1 What is the most common relationship within a relational database? Select the best answer...

    QUESTION 1 What is the most common relationship within a relational database? Select the best answer from the following. One-To-One relationship. o One-To-Many relationship. Many-To-Many relationship. Zero-To-Zero relationship. QUESTION 2 What is an "entity'? Select the best answer from the following. An entity, for our purposes, is the same as a table in the database. An entity represents one of the columns in an individual table. There are no entities in a relational database. Entities are only part of NoSQL...

  • Create the database and tables for the database. Show all SQL statements. Include primary and foreign...

    Create the database and tables for the database. Show all SQL statements. Include primary and foreign keys. Insert data into each table. Show select statements and display the output of each table. Note:Student’s name must be inserted into table as part of the data! Perform the SQL below: Query one table and use WHERE to filter the results. The SELECT clause should have a column list, not an asterisk (*). State the purpose of the query; show the query and...

  • This is questions of Accounting Information Systems 1) Fo a database. Each row in this spreadsheet...

    This is questions of Accounting Information Systems 1) Fo a database. Each row in this spreadsheet represents a: ur Tet Industries tracks customer information using various Microsoft Excel spreadsheets stored in a. Field b. Record c. File d. Database 2) A d tables is a. What is the correct term for the database field in Table 1? latabase field in Table 1 that serves as a unique identifier in Table 2 and is used to link both of the a....

  • Q.5] Answer the following questions based on the company database (based on the homework assignment 2) y dat...

    Q.5] Answer the following questions based on the company database (based on the homework assignment 2) y database (based on the homework assignment 2) 3 IPage 1. For each department whose average employee salary is more than $30,000, write a SQL statement to retrieve the department name and the number of employees working for that department 2. Write a SQL statement to retrieve first name, last name, and address of each employee who lives in Houston, TX. 3. Write a...

  • Due to your experience in designing the database for the "Legendary League" game, you have been...

    Due to your experience in designing the database for the "Legendary League" game, you have been asked to design the ER diagram for a bigger database to manage the events for the "Legendary League" eSports Oceanic Championship (OC). The requirements are as follows: Registered teams compete in the OC. Each team has a name, and a number of team members. A team also maintains a rank throughout the OC, reflecting how well it is doing in the championship. Team members...

  • Write the following SQL statements in Microsoft Access by using the Books database from Week 2...

    Write the following SQL statements in Microsoft Access by using the Books database from Week 2 Assignment 2. Once complete, copy and paste the SQL statements in a Microsoft Word document: Write SQL statements: To update the publisher name from READ WITH US to READ FOR US To verify the updated name field for the publisher with ID 6 To make the following updates to the Publisher table (be careful with WHERE): Make Contact="John Travolta" for publisher with ID number...

  • Project Description In this project, you will design and implement a database for keeping track of...

    Project Description In this project, you will design and implement a database for keeping track of information for an online “SOCIAL NETWORK” system (e.g. a simplified version of Facebook!). You will first design an EER schema diagram for this database application. Then, you will map the EER schema into a relational database schema and implement it on ORACLE or MySQL or some other relational DBMS. Finally, you will load some data into your database (via user Interface) and create some...

  • Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and...

    Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and phones of all swimmers currently in level (of id) 3. +-------+---------+---------------------------+ | FName | LName   | EMail                     | +-------+---------+---------------------------+ | Bobby | Khan    | theBKhan1 | | Clara | Johnson | ClaraJohnson_11 | +-------+---------+---------------------------+ 2 rows in set (0.00 sec) (2) Provide the names of swimmers who have signed up to participate in the event '100M Butterfly' of Meet id 1. +-------+---------+ | FName...

  • (MMU) has decided to consolidate the functionality of three small overlapping database systems, which support applications...

    (MMU) has decided to consolidate the functionality of three small overlapping database systems, which support applications for 1) teaching (e.g. instructor assignment and evaluation), for 2) registration (e.g. online course status, waiting lists), and for 3) student records (e.g. transcript generation) The resulting new system will support the following enterprise description: Professors and GTAs are assigned to teach the sections of each class being offered in a semester. At the end of the semester, they get a "team rating" (professors...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT