Question: Using SQL, I created 4 tables although I am not even sure if my created tables are working. Here are the question. Archiving old data
Using SQL, I created 4 tables although I am not even sure if my created tables are working.
Here are the question.
Archiving old data from database table:
a. Create an OldBooking table to archive/move data rows from the Booking table. [Hint: Think carefully about needed and unnecessary constraints (PK, FKs, CHECK, etc.) for OldBooking.]
b. Using the INSERT statement, copy the rows with dateTo before 2020-
01-01 from the Booking table to the OldBooking
archive table.
c. Then remove from Booking all booking rows with dateTo before 2020-
01-01.
And there are 4 tables below.
CREATE TABLE Hotel (hotelNo CHAR(8) NOT NULL ,hotelName VARCHAR2(20) NOT NULL ,city VARCHAR2(30) NOT NULL ,CONSTRAINT PKHotel PRIMARY KEY (hotelNo) );
CREATE DOMAIN RoomNumber AS CHAR(8) CHECK(VALUE BETWEEN 1 AND 100);
CREATE DOMAIN RoomType AS CHAR(8) CHECK(VALUE IN('Single', 'Double', 'Family'));
CREATE DOMAIN Price AS DECIMAL(6,2) CHECK(VALUE BETWEEN 10.00 AND 100.00);
CREATE TABLE Room (roomNo RoomNumber NOT NULL ,hotelNo CHAR(8) NOT NULL ,roomType RoomType NOT NULL ,price Price NOT NULL ,CONSTRAINT PKRoom PRIMARY KEY (roomNo) ,CONSTRAINT FKHotel FOREIGN KEY (hotelNo) REFERENCES Hotel ON DELETE SET NULL ON UPDATE CASCADE );
CREATE TABLE Guest (guestNo CHAR(8) NOT NULL ,guestName VARCHAR2(20) NOT NULL ,guestAddress VARCHAR2(30) NOT NULL ,CONSTRAINT PKGuest PRIMARY KEY (guestNo) );
CREATE TABLE Booking (hotelNo CHAR(8) NOT NULL ,guestNo CHAR(8) NOT NULL ,dateFrom TIMESTAMP NOT NULL ,dateTo TIMESTAMP NOT NULL ,roomNo RoomNumber NOT NULL ,CONSTRAINT PKBooking PRIMARY KEY (dateFrom) ,CONSTRAINT FKBooking1 FOREIGN KEY (hotelNo) REFERENCES Hotel ON DELETE SET NULL ON UPDATE CASCADE ,CONSTRAINT FKBooking2 FOREIGN KEY (guestNo) REFERENCES Guest ON DELETE SET NULL ON UPDATE CASCADE );
Please help me.
btw for the domain codes, when I try to execute it in the sqlplus, I get error saying something like this.
CREATE DOMAIN RoomNumber AS CHAR(8) 2 CHECK(VALUE BETWEEN 1 AND 100); CREATE DOMAIN RoomNumber AS CHAR(8) * ERROR at line 1: ORA-00901: invalid CREATE command
Also when I try to run tables Room and Booking in sql plus, I get this error.
ERROR at line 8: ORA-00907: missing right parenthesis
ERROR at line 9: ORA-00907: missing right parenthesis
I seriously have no idea why it's happening. It would be so helpful if someone can tell me
why I am having these errors.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
