Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

DESPERATE FOR HELP. SQL DEVELOPEMENT. CAN PAY FOR THIS TO BE DONE. Task 1. Creat

ID: 3706149 • Letter: D

Question

DESPERATE FOR HELP. SQL DEVELOPEMENT. CAN PAY FOR THIS TO BE DONE.

Task

1. Create the following tables using the SQL CREATE commands. Be sure to include in the CREATE statement not only the definitions of the columns (giving each a name, and specifying the data type for each), but also the definition of the primary keys and foreign keys as well. Create CHECK constraints to enforce the domain constraints indicated. The columns have the following data types:

SHIP. Primary key: {Ship_Name}

CRUISE. Primary key: {Cruise_ID}

RESERVATION. Primary key: {Cruise_ID, Pass_ID} <-- NOTE!!!!

PASSENGER. Primary key: {Pass_ID}

2. Insert the data shown into the tables. You should use one INSERT command for each row of data. (In Oracle, when inserting currency values, don't try to insert the '$' or ',' marks.)

SHIP

CRUISE   Note: Use an Oracle sequence to insert the Cruise_ID. Call the sequence cruise_id_sq .

RESERVATION

PASSENGER

3. List the name, size, passenger capacity, and crew capacity of each ship.

4. List the names and registry of all ships with a “Contemporary” lifestyle.

5. List the Cruise ID, the departure date, and ship name for all cruises departing from Miami.

6. List the Cruise ID, departure date, and departure city of all cruises longer than 5 days in duration.

7. List the name and registry of all ships used in a cruise that departs from Miami. (Use the IN + subquery construct.)

8. List the name of all passengers with a reservation on a cruise that departs from Miami. (Use the IN + subquery construct.)

9. List the name of all passengers who have requested a Vegetarian diet on a cruise. Include the name of the ship in query output. (Do a join.)

10. List the names of all passengers with a reservation on a cruise that departs from Miami on 25-May-15. Include the name of the ship in the query output. (Do a join.)

11. List the names of all passengers with a reservation on a cruise on a ship registered in Liberia.

12. List all ship names. For those ships used on a cruise, include the cruise departure city, departure date, and duration.

13. List the Cruise ID, ship name, departure date, and departure city for all cruises departing in June, 2015. (use BETWEEN)

14. List the total number of ships registered in Liberia.

15. List, for each ship, the total number of cruises using that ship.

16. List the total balance due for all reservations. (Result should have a single row).

17. For each cruise, list the cruise ID, the ship name, the departure date, the departure city, and the total number of passengers on that cruise.

18. List the same information as in #17, but show only those cruises with fewer than 3 reservations.

19. List the ship name, size, and service entry date of the largest ship (greatest size). The query should return one row of data. You may not provide any specific values in the WHERE clause (e.g., 'WHERE ship_size = 142000' is not permitted.)

20. Passenger 48596 has paid the remaining balance on his reservation on cruise #5. Make the appropriate change to the database.

21. Cruise #1 has been cancelled, due to hurricane danger. Do what is necessary to delete this cruise and the associated reservations from the database. (In a production database, such an event would not cause data to be deleted; rather, the cruise would be marked as cancelled in some way. But this isn’t a production database, and we need to practice deleting data, so…. )

22. Add a constraint to the Ship table to limit the Ship_Lifestyle values to: Contemporary, Premium, Luxury.

23. Create a view that displays the passenger name, telephone number, and balance due for those passengers who have a positive balance due.

24. For each ship, list the departure date and departure city of that ship’s cruise(s) with the longest duration. (There should be one row for each ship that is used for a cruise.)

25. Create an index on the Ship_Name column in the Cruise table.

Column Name Data Type Domain Key information Ship_Name VARCHAR(100) Primary key Ship_Size INTEGER > 0 Ship_Registry VARCHAR(50) possible values are: Norway, Liberia, The Netherlands, Jamaica, Bahamas Ship_ServEntryDate INTEGER Ship_PassCapacity INTEGER Ship_CrewCapacity INTEGER Ship_Lifestyle VARCHAR(40)

Explanation / Answer

Part 1) Creating all the tables with the given fields and constraint. Run the create statement in the sequence I have provided below.

// Creating table SHIP

CREATE TABLE SHIP

(

Ship_Name VARCHAR(100),

Ship_Size INTEGER,

Ship_Registry VARCHAR(50) CHECK (Ship_Registry > 0),

Ship_ServEntryDate INTEGER,

Ship_PassCapacity INTEGER,

Ship_CrewCapacity INTEGER,

Ship_Lifestyle VARCHAR(40),

PRIMARY KEY (Ship_Name),

CONSTRAINT reg_cons CHECK (Ship_Registry IN ('Norway', 'Liberia', 'The Netherlands', 'Jamaica', 'Bahamas'))

);

// Creating table Cruise

CREATE TABLE CRUISE

(

Cruise_ID INTEGER,

Ship_Name VARCHAR(100),

Cruise_DeptDate DATE NOT NULL,

Cruise_DepCity VARCHAR NOT NULL(80),

Cruise_Duration INTEGER,

PRIMARY KEY (Cruise_ID),

FOREIGH KEY (Ship_Name) REFERNCES SHIP (Ship_Name)

);

// Creating table Passenger

CREATE TABLE PASSENGER

(

Pass_ID INTEGER,

Pass_Name VARCHAR(100) NOT NULL,

Pass_City VARCHAR(80),

Pass_Telephone VARCHAR(15),

Pass_NextOfKin VARCHAR(100),

PRIMARY KEY (Pass_ID)

);

// Creating table Reservation

CREATE TABLE RESERVATION

(

Pass_ID INTEGER,

Cruise_ID INTEGER,

Res_TotalCost NUMERIC(9,2) CHECK (Res_TotalCost >= 0),

Res_BalanceDue NUMERIC(9,2) CHECK (Res_BalanceDue >=0),

Res_SpecialRequest VARCHAR(30) CHECK (Res_SpecialRequest IN ('Vegetarian', 'Vegan', 'Low salt', 'Gluten free', 'Kosher', 'Other'),

Res_Room VARCHAR(10).

PRIMARY KEY (Pass_ID, Cruise_ID),

FOREIGN KEY (Pass_ID) REFERENCES PASSENGER (Pass_ID),

FOREIGN KEY (Cruise_ID) REFERENCES CRUISE (Cruise_ID)

);

Part 2)

// Inserting records to SHIP table

INSERT INTO SHIP VALUES ('Carribean Princess', 142000, 'Liberia', 1000, 3100, 1101, 'Contemporary');

INSERT INTO SHIP VALUES ('Carribean Sunshine', 74000, 'Norway', 1992, 1950, 760, 'Premium');

// Inserting records to Cruise table

INSERT INTO CRUISE VALUES (1, 'Sunshine of the Seas', '25-May-15', 'Miami', 10);

INSERT INTO CRUISE VALUES (2, 'Carribean Princess', '15-Jun-15', 'San Juan', 7);

INSERT INTO CRUISE VALUES (6, 'Carribean Princess', '01-Jun-15', 'Ft. Lauderdale', 10);

// Inserting record to Passenger table

INSERT INTO PASSENGER VALUES (23451, 'Thomas MoCoy', 'San Francisco', '(415) 832-2121', 'John McCoy');

INSERT INTO PASSENGER VALUES (48596, 'John Perkins', 'Harrisburg', '(717) 876-3457', 'Carl Perkins');

// Inserting records into Reservation Table

INSERT INTO RESERVATION VALUES (23451, 6, 1200, 150, 'Kosher', 'A465');  

INSERT INTO RESERVATION VALUES (48591, 1, 899, 0, 'Vegetarian', 'A423');

Note- As the question is long enough and contains many parts to be completed in the given time frame, please break the rest question into part and re submit.