Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the database, each customer may own one or more vehicles, each vehicle may have one or more orders placed on it at different time,

In the database, each customer may own one or more vehicles, each vehicle may have one or more orders placed on it at different time, each order may contain one or more services, and each service has its specific rate. There are 8 tables in this database as shown below. For a single service, its cost is calculated by labor hours labor cost per hour + part cost, thus the cost of an order is the sum of all the service costs associated with this order, the total spending cost of a vehicle is the sum of all the order costs associated with this vehicle, and the total expense of a customer is the sum of all the spending costs of the vehicles owned by this customer.

Write an sql query:

Which customer spent the most in this auto shop? List the first name, last name, customer id and total expense of the customer.

List the vehicle id, year, make, model, mileage, number of the associated orders and total spending cost of vehicles.

image text in transcribed

Data Type Fields customer id first mame last mame Table thl customer not mull not null not mull 45 45 ip code Primary key: customer id Table Data Typo bl vehive vehicle id auto increment VIN 45 not nall not nall not nall not nall 45 Primary key vehicle id Table Data Typ Notes tbl order order id not nall end time not nall Primary key order id Table Data Typ service id auto increment not nall not nuall not nall not null tbl service labor hour part cost Primary key service_id Foreign key: rate id references tbl rate Table Fields Data Type Netes auto increment not nall labor cost per hour Primary key: rale id Table Data Type Length bl customer vehicle customer wehicle idinleger custoemer id not null vehicle id not null Foeeign key I: customer id references tbl customer Foreign key 2: vehicle id references tbl vehicle Table Data Type Length bl vchicle orderchicle oeder id vehicle id nicest not null order id nol null Foreign key l: vehiele id references tol _vehicle Foreign key 2: order id references tbl order Table Ficlds Data Type Length Notes bl order serviceorder service idinteger order id not null service id not null Primary key: order service i Foreign key 1:order id references tbl order Foreign key 2: service id references ibl service

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago