Question

In: Computer Science

Question 1: Car Dealership Scenario. Complete parts A – D based on the database specifications listed...

Question 1: Car Dealership Scenario. Complete parts A – D based on the database specifications listed below.

Database Specification

  • Car Dealerships have a unique business id number, dealership name, city, state, and a unique website URL. The business id is a number in the range from 1000-9999.
  • Salespersons have a first name, last name, age, gender, and a unique employee id number. The employee number is in the range 100-999.
  • Customers have a first name, last name, city, state, gender, age, and a unique taxpayer id number. The taxpayer id number is 9 digits.
  • Cars have a make, model, year, suggested price, and a unique vehicle id number. A car can have (possibly multiple) colors that should be modeled as an attribute. Note: the make of a car is the manufacturer (e.g., Ford, Honda, BMW) and the model is the name of the model (e.g. Civic, Accord, CRX).
  • Salespersons work for dealerships. In order to be in the database, a salesperson must work for a dealership. However, a dealership may exist in the database without any salespersons. Dealerships have many salespersons who work for them, and a salesperson may work for many different dealerships. The database should record the start date when a salesperson began working for a dealership.
  • Dealerships own cars. A dealership may own many cars, or they may be completely out of inventory and own zero cars. A car can only be owned by one dealership, and must be owned by a dealership in order to be in the database. The database should record the date that the dealership acquired the car and the price that the dealership paid for the car.
  • Salespersons sell cars to customers. Even if a salesperson has not sold any cars to customers they should still be stored in the database. However, the database should only store information about customers who have purchased a car from a salesperson. Information about cars owned by dealerships should be stored in the database regardless of whether they have been sold or not. A salesperson may sell a particular car to only one customer. Similarly, a customer may purchase a particular car from only one salesperson. However, a customer may purchase more than one car from the same salesperson. When a salesperson sells a car to a customer, the sales price and date should be recorded in the database.

Parts A - D

  1. Based on the database specification given above, draw an ER diagram for the database. Include entities, attributes, relationships, cardinality, and participation constraints. The ER diagram should accurately reflect the specifications.  Clearly state any assumptions.

  1. Map your ER diagram to relations. Make sure to represent the relations, attributes, primary keys, and foreign keys.

  1. Implement your database. Based on your ER and relation diagrams, create tables, specify primary and foreign keys, and include any other necessary integrity constraints such as checks. Turn in a list of the SQL DDL commands (e.g., create table commands) that you used to create your database.
  1. Populate your database with data. You may do this either by writing SQL insert statements to load data, or by using the data entry or import features of MySQL Workbench. You need to create enough and appropriate data to illustrate that your database works for the queries below. At a minimum, load at least three records for each table. However, you may need to load more records to illustrate that particular queries work correctly.

  1. Write and run SQL queries in MySQL Workbench for each of the queries listed below using your database with the data loaded. In your report, for each query, restate the query in English, then list the SQL query you wrote for it, and finally, list the output from the database in response to the query.

Queries: Write and run SQL queries for the following questions. Use the minimum number of tables required for each query.

  1. List the first and last names of customers over 40 years old who purchased a Ford car.
  2. List the first and last names of salespersons who have NEVER sold a Ford car.
  3. List the total value (suggested price) of all cars owned by the dealership named ‘SILS Car Deals’.
  4. Find the average sales price (actual sales price, not suggested price) of a 2008 Honda Civic.
  5. List the dealership name and the total number of cars that each dealership owns.
  6. List the average age of customers who have purchased a car from salesperson ‘Homer Simpson’.
  7. List the last name, employee id number, and the overall number of cars sold by each salesperson who has sold at least one Honda Civic.
  8. List the names of salespersons who have worked for all the car dealerships.

Solutions

Expert Solution

SQL queries :

i) We have to make a relational table for the cars sold to the customers by the salesperson. Hence the table will contain attributes from the tables Customer, Salesperson & Cars. The query will be :
SELECT FIRST_NAME, LAST_NAME FROM PURCHASE WHERE AGE>40 AND MAKE='FORD'

ii) We have created a PURCHASE table as described in the solution above and hence we can use this table and the Salesperson table. The query will be :

SELECT FIRST_NAME, LAST_NAME FROM SALESPERSON WHERE EMPLOYEE_ID NOT IN (SELECT EMPLOYEE_ID FROM PURCHASE WHERE MAKE='FORD')

iii) We can build a table OWNS to store data for which dealer bought which car and now owns it. We can then use this table to answer this query as it will contain data from both DEALERS and CARS table:

SELECT SUM(SUGGESTED_PRICE) FROM OWNS WHERE DEALERSHIP_NAME='Sils Car Deals'

iv) The PURCHASE table will have all the information of cars purchased by any customer and also cars sold by the salespersons and also the price at which deal is made between the two. Hence we can use this to solve this query:

SELECT AVG(ACTUAL_PRICE) FROM PURCHASE WHERE YEAR='2008' AND MAKE='HONDA' AND MODEL='CIVIC'


Related Solutions

Scenario: Suppose you are earning $57,000 a year as a sales representative for a car dealership...
Scenario: Suppose you are earning $57,000 a year as a sales representative for a car dealership at some point you decide to open a used car dealership to sell used cars. You invest $30,000 of savings that have been earning you $2000 per year. And you decide that your new firm will occupy a parking lot that you own and have been renting out for $6000 per year. You hire one clerk to help you in the store, paying her...
Scenario: Suppose you are earning $57,000 a year as a sales representative for a car dealership...
Scenario: Suppose you are earning $57,000 a year as a sales representative for a car dealership at some point you decide to open a used car dealership to sell used cars. You invest $30,000 of savings that have been earning you $2000 per year. And you decide that your new firm will occupy a parking lot that you own and have been renting out for $6000 per year. You hire one clerk to help you in the store, paying her...
For each scenario listed below, indicate how you would handle the situation. Scenario 1: a car...
For each scenario listed below, indicate how you would handle the situation. Scenario 1: a car 16-year-old Hispanic driver was in a car accident and is unconscious. You read in her personal information; her mother is a stay at home mom. Her father works at local busy accounting firm. Both of their phone numbers are listed. Who do you call first and why? Scenario 2: You are in a consult discussing a serious medical condition with a couple. The woman...
Question 1. A simple random sample survey of a large car dealership collects information on the...
Question 1. A simple random sample survey of a large car dealership collects information on the average hours worked and the average amount of commission collected by employees. There are 112 employees and the overall average number of hours worked is 21. The data table is given below. Part i) Build a 95% percent confidence interval for the mean commission and the total commission Part ii) Using ratio estimation, what should the minimum sample size be to be accurate to...
QUESTION # 2 C. The General Manager (GM) of a car dealership is working on a...
QUESTION # 2 C. The General Manager (GM) of a car dealership is working on a three-year business plan. The GM expects inflation to rise over the next three years. • How will higher inflation affect the number of vehicles the dealership can sell? • Based on the GM’s inflation expectation what type of loan should the dealership arrange with its bank in order finance its inventory of automobiles?
For the given functions f and​ g, complete parts​ (a)-(h). For parts​ (a)-(d), also find the...
For the given functions f and​ g, complete parts​ (a)-(h). For parts​ (a)-(d), also find the domain. f left parenthesis x right parenthesis equals StartFraction 7 x plus 9 Over 9 x minus 7 EndFractionf(x)=7x+99x−7​; g left parenthesis x right parenthesis equals StartFraction 9 x Over 9 x minus 7 EndFractiong(x)=9x9x−7​(a) Find ​(fplus+​g)(x). ​(fplus+​g)(x)equals=nothing ​(Simplify your​ answer.)What is the domain of fplus+​g? Select the correct choice below​ and, if​ necessary, fill in the answer box to complete your choice. A.The...
5. Felix Stamp owns a car parts dealership. Most of his payments from customers are made...
5. Felix Stamp owns a car parts dealership. Most of his payments from customers are made in cash and by direct deposit to the bank. He has few debtors. The cash book page for the month of March 2019 has been mistakenly removed. He has to rely on his source documents, ledgers and bank statement to recreate certain accounts. i. Name a source document that Felix Stamp would use to draw up his Petty Cash Book. (1 mark) ii. Felix...
1/ Assume you purchased a car that costs $14,000. The car dealership is offering financing at...
1/ Assume you purchased a car that costs $14,000. The car dealership is offering financing at 5% per year. How much is your annual payment assuming you financed the car for 5 years? How much did the car actually cost? 2/ At the beginning of the season on April 1, Green Acres Golf Course completed a physical inventory count and found that $3,000 of inventory was still on hand. Throughout the month of April, Green Acres had the following purchase...
Assume that the differences are normally distributed. Complete parts ​(a) through ​(d) below. Observation 1 2...
Assume that the differences are normally distributed. Complete parts ​(a) through ​(d) below. Observation 1 2 3 4 5 6 7 8 Upper X Subscript i 40.9 50.0 44.6 42.9 47.2 48.7 51.4 50.2 Upper Y Subscript i 45.6 48.3 46.4 47.8 50.1 50.2 53.2 50.6 ​(a) Determine d Subscript i Baseline equals Upper X Subscript i Baseline minus Upper Y Subscript i for each pair of data. Observation 1 2 3 4 5 6 7 8 di nothing nothing...
1. Use the sample data and confidence level given below to complete parts​ (a) through​(d). A...
1. Use the sample data and confidence level given below to complete parts​ (a) through​(d). A research institute poll asked respondents if they felt vulnerable to identity theft. In the poll, n=1072 and x=569 who said​ "yes." Use a 95% confidence level. ​a) Find the best point estimate of the population proportion p. (Round to three decimal places as​ needed.) ​ b) Identify the value of the margin of error E. ​(Round to three decimal places as​ needed.) ​c) Construct...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT