Question

In: Computer Science

'driver', 'car', 'accident' and 'report' are names of some tables in the insurance database system. These...

'driver', 'car', 'accident' and 'report' are names of some tables in the insurance database system. These tables were created by executing the following SQL creation statements.

CREATE TABLE driver( driverID INT NOT NULL PRIMARY KEY, name VARCHAR(30) NOT NULL, cityAddress VARCHAR(25) );

CREATE TABLE car( plateID INT NOT NULL PRIMARY KEY, model VARCHAR(20) NOT NULL, year YEAR(4) NOT NULL );

CREATE TABLE accident( reportNumber INT NOT NULL PRIMARY KEY, date Date NOT NULL, location VARCHAR(20) NOT NULL );

CREATE TABLE report ( reportNumber INT NOT NULL, plateID INT NOT NULL, driverID INT NOT NULL, damageAmount DOUBLE );

Based on the previous SQL creation statements, you are required to write each of the following queries in SQL.

1- List the models of all cars which were not involved in any accident.

2- List the names and addresses of all drivers who were not involved in any accident.

Solutions

Expert Solution

1) List models of all cars which were not involved in any accident.

Explanation: Subquery will return all models which are involved in accident and from outer query we are retrieving all models which are not involved in any accident.

Query:

SELECT MODEL FROM CAR WHERE MODEL NOT IN (SELECT MODEL FROM CAR CR, REPORT RP, ACCIDENT AC WHERE CR.plateID = RP.plateID and RP.reportNumber = ac.reportNumber);

2) List the names and addresses of all drivers who were not involved in any accident.

Explanation: Subquery will return all the driverid's who are involved in accident and the outer select query will retrieve name, cityaddress of drivers who are not involved in accident based on NOT IN condition.

Query:

SELECT NAME, CITYADDRESS FROM DRIVER WHERE DRIVERID NOT IN (SELECT RP.DRIVERID FROM REPORT RP , ACCIDENT AC WHERE AC.reportNumber = RP.reportNumber);


Related Solutions

There has been a car accident and the driver if the car was brought to PRU....
There has been a car accident and the driver if the car was brought to PRU. She has been stabilized in the emergency department; however, transferring her to another facility 40 miles to ICU away would not be appropriate in her health status for her injuries would not sustain life. The patient has to be placed in ICU in the next 1-2 hours. The night supervisory gains composure and describes the status of patients occupying the 4 ICU beds. Patient...
Scenario # 7 There has been a car accident and the driver if the car was...
Scenario # 7 There has been a car accident and the driver if the car was brought to PRU. She has been stabilized in the emergency department; however, transferring her to another facility 40 miles to ICU away would not be appropriate in her health status for her injuries would not sustain life. The patient has to be placed in ICU in the next 1-2 hours. The night supervisory gains composure and describes the status of patients occupying the 4...
Case 7 There has been a car accident and the driver if the car was brought...
Case 7 There has been a car accident and the driver if the car was brought to PRU. She has been stabilized in the emergency department; however, transferring her to another facility 40 miles to ICU away would not be appropriate in her health status for her injuries would not sustain life. The patient has to be placed in ICU in the next 1-2 hours. The night supervisory gains composure and describes the status of patients occupying the 4 ICU...
A car insurance company suspects that the younger the driver is, the more reckless a driver...
A car insurance company suspects that the younger the driver is, the more reckless a driver he/she is. They take a survey and group their respondents based on age. Of 217 respondents between the ages of 16-25 (Group 1), 183 claimed to wear a seat belt at all times. Of 398 respondents who were 26+ years old (Group 2), 322 claimed to wear a seat belt at all times. Find a 95% confidence interval for the difference in proportions. Can...
You hear a report on the news that an individual was in a car accident and...
You hear a report on the news that an individual was in a car accident and has lost the ability to move their legs. What part of the central nervous system would have been damaged in this individual? Select one: a. Spinothalamic tract b. Corticospinal tract c. Brain stem d. Cerebellum
You’re an accident investigator at a scene where a drunk driver in a 2300 kg car...
You’re an accident investigator at a scene where a drunk driver in a 2300 kg car has plowed into a 2000 kg parked car with its brake set. You measure skid marks showing that the combined wreckage moved 27 m before stopping, and you determine a frictional coefficient of 0.74. What do you report for the drunk driver’s speed just before the collision?
1. Two cars are involved in a car accident with the following facts: Tim, the driver...
1. Two cars are involved in a car accident with the following facts: Tim, the driver of car two is behind Oliver the driver of car one. Oliver uses his left turn signal and moves to the left turning lane but after he does this he changes his mind and immediately pulls back into the right driving lane but does not signal before moving into the driving lane. As he does this, Tim slams on the brakes but his car...
car insurance company suspects that the younger the driver is, the more reckless a driver he/she...
car insurance company suspects that the younger the driver is, the more reckless a driver he/she is. They take a survey and group their respondents based on age. Of 217 respondents between the ages of 16-25 (Group 1), 183 claimed to wear a seat belt at all times. Of 398 respondents who were 26+ years old (Group 2), 322 claimed to wear a seat belt at all times. Find a 95% confidence interval for the difference in proportions. Can it...
A car accident expert is assigned to a case where the insurance company suspects the car...
A car accident expert is assigned to a case where the insurance company suspects the car company to use lower quality steel (lower TS) than the standards in their bumpers. The expert is given a post-crash bumper to run his test on. Since the bumper is completely deformed, he cannot place it into the normal bumper tensile tester. He is thinking about running a hardness test on the deformed bumper to estimate the TS of the steel to test the...
Consider the database of a car rental company that contains three tables drivers, cars and reservation...
Consider the database of a car rental company that contains three tables drivers, cars and reservation tables. Drivers:                                           Reservation:                              Cars: Dno Dname age Dno Cno Day Cno Cmake Color 22 Dustin 45 22 101 10/10 101 BMW Blue 29 Brutus 33 22 102 10/10 102 VW Red 31 Lubber 55 22 103 10/8 103 OPEL Green 32 Andy 25 22 104 10/7 104 FIAT Red 58 Rusty 35 31 102 11/10 64 Horatio 35 31 103 11/6 71 Zorba...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT