55 lines
1.6 KiB
SQL
55 lines
1.6 KiB
SQL
CREATE TABLE Customer(
|
|
customerID NUMBER,
|
|
firstName VARCHAR2(15),
|
|
lastName VARCHAR2(15),
|
|
address VARCHAR2(30),
|
|
phone NUMBER(10),
|
|
CONSTRAINT Customer_pk PRIMARY KEY(customerID),
|
|
CONSTRAINT Customer_U1 UNIQUE(firstName, lastName, phone),
|
|
CONSTRAINT Customer_phoneNumber_Val CHECK (phone IS NOT NULL)
|
|
);
|
|
CREATE SEQUENCE customerID_seq;
|
|
|
|
CREATE TABLE Company(
|
|
companyName VARCHAR2(15),
|
|
stockSymbol CHAR(4),
|
|
website VARCHAR2(40),
|
|
CONSTRAINT Company_pk PRIMARY KEY(companyName),
|
|
CONSTRAINT Company_stockSymbol_U UNIQUE(stockSymbol)
|
|
);
|
|
|
|
CREATE TABLE Cruise(
|
|
cruiseID NUMBER,
|
|
cruiseName VARCHAR2(25),
|
|
departurePort VARCHAR2(20),
|
|
days NUMBER(2),
|
|
companyName VARCHAR2(15),
|
|
shipName VARCHAR2(30),
|
|
price NUMBER(7, 2),
|
|
CONSTRAINT Cruise_pk PRIMARY KEY(cruiseID),
|
|
CONSTRAINT Cruise_companyName_fk FOREIGN KEY (companyName) REFERENCES Company(companyName)
|
|
);
|
|
CREATE SEQUENCE cruiseID_seq;
|
|
|
|
CREATE TABLE TravelAgent(
|
|
travelAgentID NUMBER,
|
|
firstName VARCHAR2(15),
|
|
lastName VARCHAR2(20),
|
|
title VARCHAR2(15),
|
|
salary NUMBER(7, 2),
|
|
CONSTRAINT TravelAgent_pk PRIMARY KEY(travelAgentID)
|
|
);
|
|
CREATE SEQUENCE travelAgentID_seq;
|
|
|
|
CREATE TABLE Reservation(
|
|
reservationID NUMBER,
|
|
customerID NUMBER,
|
|
cruiseID NUMBER,
|
|
travelAgentID NUMBER,
|
|
travelDate DATE,
|
|
CONSTRAINT Reservation_pk PRIMARY KEY(reservationID),
|
|
CONSTRAINT Reservation_customerID_fk FOREIGN KEY (customerID) REFERENCES Customer(customerID),
|
|
CONSTRAINT Reservation_cruiseID_fk FOREIGN KEY (cruiseID) REFERENCES Cruise(cruiseID),
|
|
CONSTRAINT Reservation_travelAgentID_fk FOREIGN KEY (travelAgentID) REFERENCES TravelAgent(travelAgentID)
|
|
);
|
|
CREATE SEQUENCE reservationID_seq; |