Write a query that shows the make, model, VIN number and year of manufacture only for cars that have an auto insurance claim of any event type. If the database tables were populated, your query would not list cars that have not had a claim. CREATE TABLE CAR_MAKE ( CAR_MAKE_ID INT NOT NULL PRIMARY KEY, CAR_MAKE VARCHAR(25)); CREATE TABLE MAKE_MODEL ( MAKE_MODEL_ID INT NOT NULL PRIMARY KEY, CAR_MODEL VARCHAR(25), CAR_MAKE_ID INT, CONSTRAINT CM_MM_FK FOREIGN KEY (CAR_MAKE_ID) REFERENCES CAR_MAKE (CAR_MAKE_ID)); CREATE TABLE AUTOMOBILE ( AUTOMOBILE_ID INT NOT NULL PRIMARY KEY, VIN VARCHAR(255), MAKE_MODEL_ID INT, YEAR_OF_MANUFACTURE VARCHAR(4), CONSTRAINT AU_MM_FK FOREIGN KEY (MAKE_MODEL_ID) REFERENCES MAKE_MODEL (MAKE_MODEL_ID)); CREATE TABLE CLAIM_EVENT ( CLAIM_EVENT_ID INT NOT NULL PRIMARY KEY, EVENT_TYPE VARCHAR(255)); CREATE TABLE CLAIMS ( CLAIM_ID INT NOT NULL PRIMARY KEY, CLAIM_NUMBER VARCHAR(25), AUTOMOBILE_ID INT, CLAIM_EVENT_ID INT, CLAIM_DATE DATE, CONSTRAINT CL_AU_FK FOREIGN KEY (AUTOMOBILE_ID) REFERENCES AUTOMOBILE (AUTOMOBILE_ID), CONSTRAINT CL_EV_FK FOREIGN KEY (CLAIM_EVENT_ID) REFERENCES CLAIM_EVENT (CLAIM_EVENT_ID));
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
Write a query that shows the make, model, VIN number and year of manufacture only for cars that have an auto insurance claim of any event type. If the
CREATE TABLE CAR_MAKE (
CAR_MAKE_ID INT NOT NULL PRIMARY KEY,
CAR_MAKE VARCHAR(25));
CREATE TABLE MAKE_MODEL (
MAKE_MODEL_ID INT NOT NULL PRIMARY KEY,
CAR_MODEL VARCHAR(25),
CAR_MAKE_ID INT,
CONSTRAINT CM_MM_FK FOREIGN KEY (CAR_MAKE_ID) REFERENCES CAR_MAKE (CAR_MAKE_ID));
CREATE TABLE AUTOMOBILE (
AUTOMOBILE_ID INT NOT NULL PRIMARY KEY,
VIN VARCHAR(255),
MAKE_MODEL_ID INT,
YEAR_OF_MANUFACTURE VARCHAR(4),
CONSTRAINT AU_MM_FK FOREIGN KEY (MAKE_MODEL_ID) REFERENCES MAKE_MODEL (MAKE_MODEL_ID));
CREATE TABLE CLAIM_EVENT (
CLAIM_EVENT_ID INT NOT NULL PRIMARY KEY,
EVENT_TYPE VARCHAR(255));
CREATE TABLE CLAIMS (
CLAIM_ID INT NOT NULL PRIMARY KEY,
CLAIM_NUMBER VARCHAR(25),
AUTOMOBILE_ID INT,
CLAIM_EVENT_ID INT,
CLAIM_DATE DATE,
CONSTRAINT CL_AU_FK FOREIGN KEY (AUTOMOBILE_ID) REFERENCES AUTOMOBILE (AUTOMOBILE_ID),
CONSTRAINT CL_EV_FK FOREIGN KEY (CLAIM_EVENT_ID) REFERENCES CLAIM_EVENT (CLAIM_EVENT_ID));
Step by step
Solved in 2 steps