Bike Rental Management System
Group_11
202101006-Yash Garg
202101014-Naisheel Patel
202101018-Manan Pareek
202101025-Rishi Arora
202101028- Sahil Singh
Relational Schema:
Minimal functional dependencies
Rental_Location_ID -> Customer_rating, shop_name, phone, state_name,
city, state, pin_code, numer_of_vehicles
Registration_number -> Status, mileage, price_per_day, disable_friendly,
category, color, model, year, shop_id, insurance_id
Email -> DOB, License_No, phone, name, state, city, pin_code
Category -> Category_description
Insurance_ID -> Insurance_type, Insurance_amount, Insurance_start_date,
Insurance_ene_date
Payment_ID -> Payment_method, total_amount_paid.
Coupon_code -> Start_date, end_date, discount_percentage
Reservation_ID -> Start_date, end_date, rental_amount, status, email,
payment_id, security_amountr, insurance_id, coupon_code
Accessory_ID -> amount, type, reservation_id
Boyce Codd normal form (BCNF)
o BCNF is the advance version of 3NF. It is stricter than 3NF.
o A table is in BCNF if every functional dependency X → Y, X is the super
key of the table.
o For BCNF, the table should be in 3NF, and for every FD, LHS is super key.
Shop_details(Rental_Location_Id, Customer_rating, shop_name, phone,
state_name, city, state, pin_code, numer_of_vehicles)
Rental_Location_id is a super key so it is in bcnf
Vehicle(Registration_number, Status, mileage, price_per_day, disable_friendly,
category, color, model, year, shop_id, insurance_id)
Registration_number is a super key so it is in bcnf
User_details(Email, DOB, License_No, phone, name, state, city, pin_code)
Email is a super key so it is in bcnf
Vehicle_description(Category, Category_description)
Category is a super key so it is in bcnf
Insurance(Insurance_ID, Insurance_type, Insurance_amount,
Insurance_start_date, Insurance_end_date)
Insurance_ID is a super key so it is in bcnf
Payment_details(Payment_ID, Payment_method, total_amount_paid.
Payment_ID is a super key so it is in bcnf
Coupon_details(Coupon_code, Start_date, end_date, discount_percentage)
Coupon_code is a super key so it is in bcnf
Reservation_details(Reservation_ID,Start_date,end_date, rental_amount,
status, email, payment_id, security_amountr, insurance_id, coupon_code)
Reservation_ID is a super key so it is in bcnf
Accessories(Accessory_ID, amount, type, reservation_id)
Accessory_ID is a super key so it is in bcnf
DDL SCRIPT:
create schema bike_rental;
set search_path to bike_rental;
CREATE TABLE RENTAL_LOCATION
(
Shop_ID INT PRIMARY KEY,
Shop_Name VARCHAR(20),
Customer_rating INT ,
Phone CHAR(10),
Email VARCHAR(25),
Street_Name VARCHAR(40),
State CHAR(10) ,
PIN_Code CHAR(6)
City CHAR(20)
);
CREATE TABLE BIKE_TYPE
(
Category VARCHAR(15) PRIMARY KEY,
Category_description VARCHAR(30)
);
CREATE TABLE INSURANCE
(
Insurance_ID VARCHAR(15) PRIMARY KEY,
Insurance_amount INT,
Start_date DATE,
End_date DATE
);
CREATE TABLE BIKE_USER
(
License_No VARCHAR(15) UNIQUE,
Fname VARCHAR(15) ,
Mname VARCHAR(1),
Lname VARCHAR(15) ,
Email VARCHAR(25) PRIMARY KEY,
Phone CHAR(10) ,
DOB DATE ,
State CHAR(10) ,
PIN_Code CHAR(6)
City CHAR(20)
);
CREATE TABLE BIKE
(
Registration_No CHAR(17) PRIMARY KEY,
Shop_ID INT ,
Status VARCHAR(15),
Seating_Capacity INT ,
Disable_Friendly CHAR(1),
Category VARCHAR(15) ,
Model VARCHAR(20),
Mileage INT,
Year CHAR(4),
Color VARCHAR(10),
FOREIGN KEY (Category) REFERENCES BIKE_TYPE(Category)
ON DELETE CASCADE,
FOREIGN KEY (Shop_ID) REFERENCES
RENTAL_LOCATION(Shop_ID)
ON DELETE CASCADE
);
CREATE TABLE OFFER_DETAILS
(
Coupon_Code VARCHAR(15) PRIMARY KEY,
Start_date DATE,
End_date DATE,
Discounted_Percentage NUMBER(5,2)
);
CREATE TABLE RESERVATION
(
Reservation_ID INT PRIMARY KEY,
Start_Date DATE ,
End_Date DATE , -
Rental_Amount NUMBER(8,2) ,
Status VARCHAR(10) ,
Security_Amount NUMBER(8,2) ,
FOREIGN KEY (Email) REFERENCES BIKE_USER(Email)
ON DELETE CASCADE,
FOREIGN KEY (Coupon_Code) REFERENCES
OFFER_DETAILS(Coupon_Code)
ON DELETE CASCADE,
FOREIGN KEY (Insurance_ID) REFERENCES INSURANCE(Insurance_ID)
ON DELETE CASCADE
);
CREATE TABLE PAYMENT
(
Payment_ID INT PRIMARY KEY,
Payment_Method CHAR(10),
FOREIGN KEY (Payment_ID) REFERENCES
RESERVATION(Payment_ID)
ON DELETE CASCADE
);
CREATE TABLE ACCESSORIES
(
Accessory_ID INT PRIMARY KEY,
Type VARCHAR(15) ,
Amount NUMBER(8,2)
FOREIGN KEY (Reservation_ID) REFERENCES
RESERVATION(Reservation_ID)
ON DELETE CASCADE
);