Question

Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in...

Consider the following database schema:

LIKE(person, sport),

PRACTICE(person, sport),

where person and sport are keys in both tables. The table LIKE gives the sports a person likes, the table PRACTICE gives the sports a person practices. We assume that a person likes at least one sport and practices at least one sport. We assume also that a person does not like a sport if the sport is not listed among the sports that person likes

Express the following queries in mySQL preferred

1. List the people who practice at least one sport they do not like

2. List pairs of people who practice at least one common sport

3. List the people who like all the sports they practice

Homework Answers

Answer #1
1. List the people who practice at least one sport they do not like

select person from PRACTICE INNER JOIN 
LIKE ON PRACTICE.person = LIKE.PERSON
Group By person
Having LIKE.sport <> PRACTICE.sport AND count(PRACTICE.sport)>=1

2. List pairs of people who practice at least one common sport

select PRACTICE.sport,PRACTICE.person 
from PRACTICE
Group by sport, person
Having count(person)>=2

3. List the people who like all the sports they practice

select person as practice_person from PRACTICE
where sport in (
select sport from LIKE where person = practice_person)

******************************************************************************************
PLEASE LIKE IT RAISE YOUR THUMBS UP
IF YOU ARE HAVING ANY DOUBT FEEL FREE TO ASK IN COMMENT SECTION
******************************************************************************************

Know the answer?
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
Similar Questions
Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in...
Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in both tables. The table LIKE gives the sports a person likes, the table PRACTICE gives the sports a person practices. We assume that a person likes at least one sport and practices at least one sport. We assume also that a person does not like a sport if the sport is not listed among the sports that person likes Express the following queries in...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode)...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum*, famname, givename, initials, title) PAPER(panum, title) AUTHOR(panum*, acnum*) FIELD(fieldnum, id, title) INTEREST(fieldnum*, acnum*, descrip) Some notes on the Academics database: An academic department belongs to one institution (instname) and often has many academics. An academic only works for one department. Research papers (PAPER) are often authored by several academics, and of course an academic often writes several papers (AUTHOR). A research field...
The following is about databases: queries on relational algebra Consider the following schemas for a LinkedIn-like...
The following is about databases: queries on relational algebra Consider the following schemas for a LinkedIn-like professional network. Note this is a slightly simplified version from your last assignment. Assume that the connections are mutual. Person (PID, first_name, last_name, age, gender) School (school_ID, school_name, type, city, state) Education (PID, school_ID, degree, major, year) Company (company_ID, company_name, total_asset, headquarter) Branch (company_ID, branch_num, city, state) WorksAt (PID, company_ID, branch_num, start, end) Connection (PID, friend_ID) For each relation, the attribute(s) of the primary...
Summary The Ch08_ConstructCo database stores data for a consulting company that tracks all charges to projects....
Summary The Ch08_ConstructCo database stores data for a consulting company that tracks all charges to projects. The charges are based on the hours each employee works on each project. The structure and contents of the Ch08_ConstructCo database are shown in Figure P8.1. Use this database to answer the following problems. Database Schema The schema for the Ch08_ConstructCo database is shown below and should be used to answer the next several problems. Click this image to view it in its own...
Garden Glory Project Questions Assume that Garden Glory designs a database with the following tables: OWNER...
Garden Glory Project Questions Assume that Garden Glory designs a database with the following tables: OWNER (OwnerID, OwnerName, OwnerEmail, OwnerType) OWNED_PROPERTY (PropertyID, PropertyName, PropertyType, Street, City, State, Zip, OwnerID) GG_SERVICE (ServiceID, ServiceDescription, CostPerHour); EMPLOYEE (EmployeeID, LastName, FirstName, CellPhone, ExperienceLevel) PROPERTY_SERVICE ( PropertyServiceID , PropertyID , ServiceID, ServiceDate , EmployeeID, HoursWorked) The referential integrity constraints are: OwnerID in OWNED_PROPERTY must exist in OwnerID in OWNER PropertyID in PROPERTY_SERVICE must exist in PropertyID in OWNED_PROPERTY ServiceID in PROPERTY_SERVICE must exist in ServiceID...
***This is a complete question. Do not tag this as incomplete. Write SQL queries to the...
***This is a complete question. Do not tag this as incomplete. Write SQL queries to the below Relational Database. • Regarding the SQL queries: • Do not use SELECT * in any query. • Do not use any SQL features (including Nullif) that were not covered in this course. • Do not use subqueries IF joins can be used to answer a question. However, some questions may require the use of subqueries. The Movie Database Notes: TheaterNum, MovieNum, and ActorNum...
using mysql lyrics.database. i will provide the lyrics schema database info below 1. List the first...
using mysql lyrics.database. i will provide the lyrics schema database info below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in...
True False Select the most correct answer. Question 1 (1 point) Most databases are just in...
True False Select the most correct answer. Question 1 (1 point) Most databases are just in 1NF. Question 1 options: True False Question 2 (1 point) A subquery is always preferred over a join. Question 2 options: True False Question 3 (1 point) A database may consist only of multiple files. Question 3 options: True False Question 4 (1 point) A database may exist without a database management system. Question 4 options: True False Question 5 (1 point) The insert...
Read the case and answer the following Multiple choice questions. There are 5 questions total, where...
Read the case and answer the following Multiple choice questions. There are 5 questions total, where some of them might have more than one correct answers. You can choose more than one options where you think is suitable for the above question. PERFORMANCE MANAGEMENT Project Manager Oliver Caine skimmed his notes as he waited for Ben Robins to come to the meeting room. He hoped Ben would arrive soon, as he wanted to get the con-versation finished quickly. Ben walked...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT