Question

Assume a database has the relations shown in the appendix. The purpose of the database is...

Assume a database has the relations shown in the appendix. The purpose of the database is to correlate weather and traffic conditions with car repairs.

* Find the average number of breakdowns happened in a rainy day in “Los Angeles”.

* Find names of the owners who owned every car (considering brands and models) that John owned. You may assume John is a unique name.

* Find names of the city(s) that had the highest average congestion rate (i.e., they had the worst traffic.)

* Find the brand(s) that had the lowest average repair cost for cars whose price was over $40,000.

APPENDIX

  • owner(owner_id, name, age, city)

  • car(car_id, brand, model, year, owner_id, price)

  • repair(repair_id, car_id, problem, date, cost, city)

    //note: Problem belongs to a predefined category such as “breakdown”, //”flat_tire”, etc. Date is the date the problem occurred.

  • weather(weather_id, temp_high, temp_low, wind_level, weather_type, date, city) //note: Weather_type can be “rain”, “snow”, “cloudy”, etc.

  • traffic(traffic_id, congestion_rate, date, city)

Homework Answers

Answer #1

If you have any doubts / errors, please give me comment...

-- 1)

SELECT problem, AVG(COUNT(*)) AS avg_no_of_breakdowns

FROM repair

WHERE city = 'Los Angeles'

GROUP BY problem;

-- 2

SELECT O.name

FROM owner O, car C, owner O1, car C1

WHERE O.owner_id = C.owner_id AND O1.owner_id = C1.owner_id AND O1.name = 'John' AND C1.model = O1.model AND C1.brand = O1.brand;

-- 3

SELECT city

FROM traffic

GROUP BY city

HAVING AVG(congestion_rate) >= ALL(

SELECT AVG(congestion_rate)

FROM traffic

GROUP BY city

);

-- 4

SELECT brand

FROM cars C, repair R

WHERE C.car_id = R.car_id AND price > 40000

GROUP BY brand

HAVING AVG(cost) <= ALL(

SELECT AVG(cost)

FROM cars C1, repair R1

WHERE C1.car_id = R1.car_id AND price > 40000

GROUP BY brand

)

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
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...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT