Question

LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in both tables. The table LIKE...

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 Calculus List pairs of people who practice at least one common sport List the people who like all the sports they practice List the people who practice all the sports they like List the people who practice all the sports John likes

Homework Answers

Answer #1

1. 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

2. 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)

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

select person as like_person from LIKE

where sport in (

select sport from PRACTICE where person = like_person)

4. List the people who practice all the sports John likes

select John as like_person from LIKE

where sport in (

select sport from PRACTICE where John = like_person)

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...
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...
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...
Practice writing SQL queries ----------------------------- For this question, we will consider the following tables about people,...
Practice writing SQL queries ----------------------------- For this question, we will consider the following tables about people, grades, and courses. Your task is to express each of the given queries in SQL. Example data are provided in these tables for your convenience but note that they are only example data. Your queries must work for all potential data residing in the given tables, not just those illustrated here. People (id, name, age, address) --------------------------------------------------- p1 | Tom Martin| 24 | 11,...
C# programming Assume we have a student final exam score lookup table like this: John 40...
C# programming Assume we have a student final exam score lookup table like this: John 40 Henry 0 Mary 59 Hillary 39 Pikachu 100 Write a class that helps check if student passes or fails the course. If a student's score is greater than or equal to a parameter passScore, we will consider it a pass. If a student's name is NOT found in the table, we assume they have missed the exam and thus consider failed. The method should...
Look at the two tables below, which show, respectively, the willingness to pay and willingness to...
Look at the two tables below, which show, respectively, the willingness to pay and willingness to accept of buyers and sellers of bags of oranges. For the following questions, assume that the equilibrium price and quantity will depend on the indicated changes in supply and demand. Assume that the only market participants are those listed by name in the two tables. Also assume that each individual purchases or sells one bag of oranges. Consumers Producers Person Maximum Price Willing to...
***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...
Problem 1: Relations among Useful Discrete Probability Distributions. A Bernoulli experiment consists of only one trial...
Problem 1: Relations among Useful Discrete Probability Distributions. A Bernoulli experiment consists of only one trial with two outcomes (success/failure) with probability of success p. The Bernoulli distribution is P (X = k) = pkq1-k, k=0,1 The sum of n independent Bernoulli trials forms a binomial experiment with parameters n and p. The binomial probability distribution provides a simple, easy-to-compute approximation with reasonable accuracy to hypergeometric distribution with parameters N, M and n when n/N is less than or equal...
ACT Prep Course. ACT prep courses like to market that you can increase your ACT score...
ACT Prep Course. ACT prep courses like to market that you can increase your ACT score by taking their courses. Some statisticians were curious how effective these courses really were. They decided to investigate the truth of the claim by measuring the average score increase for a random sample of students selected to take an ACT prep course. These students took the ACT twice, once before and once after taking the course. The variable of interest was the increase in...
TOMS SHOES –Case Study Founded in 2006 by BLAKE MYCOSKIE, TOMS Shoes was an American footwear...
TOMS SHOES –Case Study Founded in 2006 by BLAKE MYCOSKIE, TOMS Shoes was an American footwear company based in Santa Monica, California. Although TOMS Shoes was a for-profit business, its mission was more like that of a not-for-profit organization. The firm’s reason for existence was to donate to children in need one new pair of shoes for every pair of shoes sold. Blake Mycoskie referred to it as the company’s “One for One” business model. While vacationing in Argentina during...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT