Database Schama For Car Rental Agency

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Consider the following car rental agency database.

Customers(CID, first_name, Last_Name, Address)


Vehicle(VID, Mileage, Location, Size, Transmission)
Reservations(CID,VID, Start_Date, End_Date)
Note :
->Vehicle.transmission can have two values manual and automatic.
->Vehicle.size can have following values. compact, mid-size, full-size, premium and
luxury. The default size is compact.

Create customers table


CREATE TABLE Customers
(
CID varchar2(5) PRIMARY KEY,
FIRST_NAME varchar2(20),
LAST_NAME varchar2(15),
ADDRESS varchar2(30)
);

Create vehicle table

CREATE TABLE Vehicle


(
VID varchar2(5) PRIMARY KEY,
MILEAGE NUMBER(7,2),
LOCATION varchar2(20),
VSIZE varchar2(30) CHECK (VSIZE IN('COMPACT','MID-SIZE','FULLSIZE','PREMIUM','LUXURY')),
TRANSMISSION varchar2(10) CHECK (TRANSMISSION IN('MANUAL','AUTOMATIC'))
);

Create reservation table


CREATE TABLE Reservation
(
CID varchar2(5) REFERENCES Customers(CID),
VID varchar2(5) REFERENCES Vehicle(VID),
START_DATE DATE,
END_DATE DATE,
PRIMARY KEY(CID,VID)
);

Description / definition of customer table


DESC CUSTOMERS;
Output :
Name
CID
FIRST_NAME
LAST_NAME
ADDRESS

Null? Type
NOT NULL VARCHAR2(5)
VARCHAR2(20)
VARCHAR2(15)
VARCHAR2(30)

Description / definition of vehicle table


DESC VEHICLE;
Output :
Name
VID
MILEAGE

Null? Type
NOT NULL VARCHAR2(5)
NUMBER(7,2)

LOCATION
VSIZE
TRANSMISSION

VARCHAR2(20)
VARCHAR2(30)
VARCHAR2(10)

Description / definition of reservation table


DESC RESERVATION;
Output :
Name
CID
VID
START_DATE
END_DATE

Null? Type
NOT NULL VARCHAR2(5)
NOT NULL VARCHAR2(5)
DATE
DATE

Insert statements
INSERT STATEMENT FOR CUSTOMER TABLE
INSERT INTO Customers
(CID,FIRST_NAME,LAST_NAME,ADDRESS) VALUES
('101','KRUNAL','PATEL','MANINAGAR,AHMD');
INSERT INTO Customers
(CID,FIRST_NAME,LAST_NAME,ADDRESS) VALUES
('102','BHAVESH','MODI','VADAJ,AHMD');
INSERT INTO Customers
(CID,FIRST_NAME,LAST_NAME,ADDRESS) VALUES
('103','DARSHAN','DERASARI','HIMANTNAGAR');
INSERT INTO Customers
(CID,FIRST_NAME,LAST_NAME,ADDRESS) VALUES
('104','VISHAL','DAVE','ISSANPUR,AHMD');
INSERT INTO Customers
(CID,FIRST_NAME,LAST_NAME,ADDRESS) VALUES
('105','SAGAR','SHAH','VATVA,AHMD');

You might also like