Question: Also this revision exercise got me stumped :/ The queries listed below must be implemented as nested SELECT statements with IN/NOT IN set membership operation.

Also this revision exercise got me stumped :/

Also this revision exercise got me stumped :/ The queries listed below

The queries listed below must be implemented as nested SELECT statements with IN/NOT IN set membership operation.

  1. Find the first and the last name of the drivers who are on leave at the moment.
  2. Find the registration numbers of trucks that are used just now and that have been used for at least one trip in 2016. The queries listed below must be implemented as nested queries with EXISTS/NOT EXISTS clauses.
  3. Find the first and last names of employees who are not drivers.
  4. Find the first and last names of drivers who performed at least one trip in 2017. A query listed below must be implemented with a set algebra operation.
  5. Find the distinct names of cities visited by a driver during trip number 1 or trip number 8. Assume that a city is visited by a driver if it is an origin or a destination or an intermediate stop of a trip.
  6. The following query must be implemented as a nested query. Find the distinct names of cities visited by a driver during trip number 1 and trip number 8. Note that we try to find the cities visited during both trips number 1 and number 8. Assume that a city is visited by a driver if it is an origin or a destination or an intermediate stop of a trip.

CREATE TABLE EMPLOYEE ( ( ENUM DECIMAL (12) NOT NULL, FNAME VARCHAR(50) NOT NULL, INITIALS VARCHAR(5) NULL, LNAME VARCHAR(50) NOT NULL, ' DOB DATE A. NULL, ' BLDG DECIMAL (3) NOT NULL, STREET VARCHAR(50) NOT NULL, ' SUBURB VARCHAR(50) NOT NULL, STATE VARCHAR(5) NOT NULL, ZIPCODE DECIMAL (4) NOT NULL, CONSTRAINT EMPLOYEE_PKEY PRIMARY KEY (ENUM)); /* RRRRRR */ CREATE TABLE DRIVER ENUM DECIMAL (12) NOT NULL, LNUM DECIMAL (8) NOT NULL, STATUS VARCHAR(10) NOT NULL, CONSTRAINT DRIVER_PKEY PRIMARY KEY (ENUM), CONSTRAINT DRIVER_UNIQUE UNIQUE (LNUM), CONSTRAINT DRIVER_FKEY FOREIGN KEY (ENUM) REFERENCES EMPLOYEE (ENUM), CONSTRAINT DRIVER_STATUS CHECK ( STATUS IN ('AVAILABLE', 'BUSY', 'ON LEAVE')); / */ CREATE TABLE ADMIN ENUM DECIMAL (12) NOT NULL, POSITION VARCHAR(50) NOT NULL, CONSTRAINT ADMIN_PKEY PRIMARY KEY (ENUM), CONSTRAINT ADMIN_FKEY FOREIGN KEY(ENUM) REFERENCES EMPLOYEE (ENUM)); /* - WWW */ CREATE TABLE TRUCK REGNUM VARCHAR(10) NOT NULL, DET CAPACITY DECIMAL (7) NOT NULL, WEIGHT DECIMAL (7) NOT NULL, STATUS VARCHAR(10) NOT NULL, CONSTRAINT TRUCK_PKEY PRIMARY KEY (REGNUM), CONSTRAINT TRUCK STATUS CHECK ( STATUS IN ('AVAILABLE', 'USED', 'MAINTAINED')), CONSTRAINT TRUCK_WEIGHT CHECK ( WEIGHT > 0.0 AND WEIGHT 0.0 AND CAPACITY

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!