Date post: | 02-Dec-2014 |
Category: |
Documents |
Upload: | wahabrana3781 |
View: | 15 times |
Download: | 0 times |
CS 352
Database Management Systems Term Project
DESIGN REPORT
Car Rental Database System
GroupID 13Cartal
http://code.google.com/p/cartal/
Murat Nalçakan Utku Can Yücel Dilara Tara Şahintepe
20800182 20702222 20802578 m_nalcakan@ug u_yucel@ug sahintepe@ug
28.03.2011
Revised ER Diagram...................................................................................................................3
FDs , Normalization of Tables and Relations.............................................................................4
Functional components.............................................................................................................10
Graphical user interface and corresponding queries.................................................................10
List possible cars for customer.........................................................................................10
Make a reservation for a specific car in specified dates...................................................11
Show Selected Costumers Details and Past Actions.........................................................13
Confirm a reservation as reserved.....................................................................................14
Add a new branch.............................................................................................................14
Add new car to a branch...................................................................................................15
Sign up for a new customer..............................................................................................16
Delete a car from specific branch.....................................................................................16
List all staff.......................................................................................................................17
Update car price................................................................................................................17
2
1- Revised ER DiagramRevised version of our ER diagram is provided below. It is logical to overview the relations before reaching detailed descriptions of the relations.
Figure 1 Revised ER Diagram
3
2- FDs , Normalization of Tables and RelationsADDRESS(
addressid INTEGER DEFAULT 0 NOT NULLzipcode INTEGER DEFAULT 0 NOT NULLcity CHAR(10) NOT NULLdetailedaddress VARCHAR(50) NOT NULLphoneno INTEGERPRIMARY KEY(addressid))
Functional Dependencies: noCandidate Key: (addressid)Normal Form 3NF
PERSON(TCidno INTEGER NOT NULLname CHAR(20) NOT NULLage INTEGER NOT NULLPRIMARYKEY TCidnoFOREIGN KEY (addressid) REFERENCES ADDRESS (addressid))
Functional Dependencies: TCidno TCidno addressidCandidate Key: TCidnoNormal Form : 3NF
SALESMAN(staffid INTEGER NOT NULLbranchid INTEGERTCidno INTEGER name CHAR(20)age INTEGER PRIMARY KEY (staffid)FOREIGN KEY (branchId) REFERENCES BRANCH(id)FOREIGN KEY (TCidno) REFERENCES PERSON(TCidno)FOREIGN KEY (name) REFERENCES PERSON(name)FOREIGN KEY (age) REFERENCES PERSON(age)FOREIGN KEY (addressid) REFERENCES PERSON(addressid))
Functional Dependencies: staffid name ageCandidate Keys: staffid, TCidno Normal Form: 3NF
DRIVER(staffid INTEGER NOT NULL,branchid INTEGER,TCidno INTEGER ,name CHAR(20),age INTEGER ,PRIMARY KEY (staffid),FOREIGN KEY (branchId) REFERENCES BRANCH(id),FOREIGN KEY (TCidno) REFERENCES PERSON(TCidno),
4
FOREIGN KEY (name) REFERENCES PERSON(name),FOREIGN KEY (age) REFERENCES PERSON(age),FOREIGN KEY (addressid) REFERENCES PERSON(addressid))
Functional Dependencies: staffid name ageTCidno name age
Candidate Keys: staffid, TCidno Normal Form: 3NF
CUSTOMER(customerid INTEGER not nullname CHAR(20)age INTEGER TCidno INTEGERPRIMARY KEY (customerid)FOREIGN KEY (name) REFERENCES PERSON(name)FOREIGN KEY (age) REFERENCES PERSON(age)FOREIGN KEY (TCidno) REFERENCES PERSON(TCidno))
Functional Dependencies: customerid name ageTCidno name age
Candidate Keys: staffid, TCidno Normal Form: 3NF
PAYMENT(payment_id INTEGER DEFAULT 0payment_type CHAR(5),payment_date DATEremaining_amount INTEGERbooking_no INTEGERPRIMARY KEY (payment_id)FOREIGN KEY (booking_no) REFERENCES BOOKING(booking_no))
Functional Dependencies: payment_id remaining_amount payment_type payment_datepayment_id booking_no
Candidate Keys: payment_id Normal Form: 3NF
BOOKING(booking_no INTEGER NOT NULLauto_id INTEGER DEFAULT 0 payment_id INTEGER DEFAULT 0booking_status CHAR(5) DEFAULT “rsrvd”pickup_date DATE,pickup_branch_id INTEGERdropoff _date DATE,dropoff_branch_id INTEGERPRIMARY KEY (booking_no)FOREIGN KEY (payment_id) REFERENCES PAYMENTFOREIGN KEY (pickup_branch_id) REFERENCES BRANCH
5
FOREIGN KEY (dropoff_branch_id) REFERENCES BRANCH)
Functional Dependencies: booking_no auto_id payment_id pickup_payment_id booking_no
Candidate Keys: (booking_no) (auto_id, payment_id)Normal Form: 3NF
BRANCH(branchid INTEGER not null,branchname CHAR(50) not null,addressid INTEGER not null,autoid INTEGER,detailed address CHAR(500),PRIMARY KEY (branchid),PRIMARY KEY(branchname),PRIMARY KEY(addressid),FOREIGN KEY(autoid) REFERENCES AUTO(autoid),FOREIGN KEY(detailed address) REFERENCES ADDRESS(detailed address),
)Functional Dependencies: branchid->autoidCandidate Key: branchidNormal Form: 3NF
AUTO(modelyear INTEGER,lastbookingno INTEGER,autocolor CHAR(20),brandname CHAR(20),modelname CHAR(30),autoid INTEGER,actiondate CHAR(30),servicedetail CHAR(500),insuranceCompany CHAR(50),branchid INTEGER,PRIMARY KEY(modelyear),PRIMARY KEY(lastbookingno),PRIMARY KEY(autocolor),PRIMARY KEY(brandname),PRIMARY KEY(modelname),PRIMARY KEY(autoid),FOREIGN KEY(actiondate) REFERENCES HISTORY(actiondate),FOREIGN KEY(servicedetail) REFERENCES SERVICECHECK(servicedetail),FOREIGN KEY(insuranceCompany) REFECENCES
ISURANCECOMPANY(Insurance Company),FOREIGN KEY(branchid) REFERENCES BRANCH(branchid),
)Functional Dependencies: autoid->branched actiondate InsuranceCompany
autoid brandname->servicedetailCandidateKeys: autoid brandnameNormal Form: 3NF
6
HISTORY(autoid INTEGER,actiondate CHAR(30),Serviceno INTEGER,PRIMARY KEY(autoid),PRIMARY KEY(actiondate),FOREIGN KEY(Serviceno) REFERENCES REPAIRJOB (Serviceno),
)Functional Dependencies: autoid->ServicenoCandidate Keys: autoidNormal form: 3NF
REPAIRJOB(Serviceno INTEGER,ServiceName CHAR(30),ServiceFee INTEGER,Autoid INTEGER,PRIMARY KEY(Serviceno),PRIMARY KEY(ServiceName),PRIMARY KEY(ServiceFee),FOREIGN KEY(autoid) REFERENCES HISTORY (autoid),
)Functional Dependencies: Serviceno->autoidCandidate Keys: ServicenoNormal Forms: 3NF
ACCIDENT(Acdetails CHAT(500),Accplace CHAR(50),Customerid INTEGER,autoid INTEGER,PRIMARY KEY(Accdetails),PRIMARY KEY(Accplace),PRIMARY KEY(Customerid),FOREIGN KEY(autoid) REFERENCES HISTORY(autoid),
)Functional dependencies: Accplace->autoidCandidate Keys: AccplaceNormal Forms: 3NF
SERVICECHECK(NextCheckDate INTEGER,Serviceid INTEGER,ServiceDetail CHAR(500),Autoid INTEGER,PRIMARY KEY(NextCheckDate),PRIMARY KEY(Serviceid),PRIMARY KEY(ServiceDetail),FOREIGN KEY(autoid) REFERENCES AUTO(autoid),
)
7
Functional Dependencies: Serviceid->autoidCandidate Keys: ServiceidNormal Forms: 3NF
INSURANCECOMPANY(InsuranceCompany CHAR(50),Amount INTEGER,Autoid INTEGER,PRIMARY KEY(InsuranceCompany),PRIMARY KEY(Amount),PRIMARY KEY(Autoid),
)
Does(customerid(6) not null,payment_id (6) not null,PRIMARY KEY (customerid),FOREIGN KEY (customerid) REFERENCES Customer(),FOREIGN KEY (payment_id) REFERENCES Payment( id),
)Candidate Keys: (customerid payment_id)Normal Form: 3NF
Requires(payment_id INTEGER(6) not null,bookingno INTEGER(6) not null,PRIMARY KEY ( payment_id ,bookingno),FOREIGN KEY (payment_id ) REFERENCES Payment(id),FOREIGN KEY (bookingno) REFERENCES Booking(bookingno),
)Candidate Keys: (payment_id bookingno)Normal Form: 3NF
Makes(customerid INTEGER(6) not null,bookingno INTEGER(6)not null,PRIMARY KEY(customer id, bookingno),FOREIGN KEY (customerid ) REFERENCES Customer(id),FOREIGN KEY (bookingno ) REFERENCES Booking(bookingid)
)Candidate Keys: (customerid,bookingno)Normal Form: 3NF
Confirms (staffid INTEGER(6)not null,bookingno INTEGER (6) not null,PRIMARY KEY (staffid, bookingno),FOREIGN KEY (staffid) REFERENCES Salesman( id) , FOREIGN KEY (bookingid) REFERENCES Booking(bookingid)
)Candidate Keys: (staffid, bookingno)
8
Normal Form: 3NF
has(staffid INTEGER(6) not null,branchid INTEGER (6) not null,PRIMARY KEY (staffid, branchid) , FOREIGN KEY (staffid) REFERENCES Person(staffid),FOREIGN KEY (branchid) REFERENCES Branch(branchid)
)Candidate Keys: (staffid,branchid)Normal Form: 3NF
Stay(staffid INTEGER(6) not null,addressid INTEGER(6) ,PRIMARY KEY(staffid),FOREIGN KEY (staffid) REFERENCES Person(staffid),FOREIGN KEY (addressid) REFERENCES Address(addressid),
)Candidate Keys: (staffid)Normal Form: 3NF
Located(addressid INTEGER(6),branchid INTEGER(6)not null,PRIMARY KEY(addressid,branchid),FOREIGN KEY (addressid) REFERENCES Address(addressid),FOREIGN KEY (branchid) REFERENCES Branch(branchid),
)Candidate Keys: (addressid)Normal Form : 3NFWorks For(
staffid INTEGER,branchid INTEGER,PRIMARY KEY(staffid, branchid)
)Candidate KEys: staffid,branchidNormal Form: 3NF
Owns(branchid INTEGER,autoid INTEGER,PRIMARY KEY(autoid,branchid),FOREIGN KEY (autoid) REFERENCES AUTO(autoid),FOREIGN KEY (branchid) REFERENCES Branch(branchid),
)Candidate Keys: branchid,autoidNormal Forms: 3NF Has(
9
autoid INTEGER,PRIMARY KEY(autoid),
)
Needs(NextCheckDate INTEGER,Serviceid INTEGER,autoid INTEGER,PRIMARY KEY(autoid, NextCheckDate, Serviceid),
)Candidate Keys: autoid, NextCheckDate, ServiceidNormal Forms: 3NF Insuaredby(
ExpirationDate INTEGER,Autoid INTEGER,InsuranceCompany INTEGER,PRIMARY KEY(ExpirationDate),FOREIGN KEY(Autoid) REFERENCES AUTO(autoid),FOREIGN KEY(InsuranceCompany) REFERENCES
INSURANCECOMPANY(InsuranceCompany))Candidate KEys: Autoid, InsuranceCompanmyNormal Forms: 3NF
3- Functional components
3.1 Use Case Diagram
There will be two types of users in our system. We will only allow Customers and Branch Staffs to use system.
Figure 2 Use Case Diagram
10
3.2 Algorithms
There will be two different algorithms which will be used for update information of discount amount and next service date.
Since this algorithm needs input from the previous servicecheck our database will initially select the previous service check of the auto.nextservicecheckdate = previousservicedate + regularcheckperiod
4- Graphical user interface and corresponding queries
List possible cars for customer
inputs( ‘branch_id’, ‘ car_brand’, ‘car_model’, ‘pickup_date’, ‘dropoff_date’, ‘totaldays’)
SELECT A.modelname A.modelyear A.brandname A.color A.carfareFROM AUTO A BRANCH B BOOKING BOOWHERE A.branch_id = ‘branch_id’ AND A.brandname = car_brand AND A.modelname = ‘car_model’ NOT EXIST (SELECT *
FROM BOOKING B2 AUTO A2WHERE B2.autoid = A2.autoid )
Make a reservation for a specific car in specified dates
User is allowed to make reservation for a car in a time period. However, user can not be able to make payment online. Only salesman can accept and confirm a payment.
inputs($autoid, $pickup_branchid, $pickup_date, $dropoff_date, )
11
INSERTINTO BOOKING(bookingno, customerid, autoid, paymentno, reservationdate,pickup_date, pickup_branchid,dropoff_date, dropoff_branchid)VALUES ($bookingno, $customerid, $autoid, $paymentno, $reservationdate , $pickup_date, $pickup_branchid, $dropoff_date, $dropoff_branchid)
INSERTINTO PAYMENT (payment_id, remaining_amount, booking_no, payment_date, payment_type)VALUES ($payment_id, $remaining_amount, $booking_no, NULL, NULL)
Previous screen sample can only show the possible cars with their daily fares. In order to complete the reservation user should decide the drop off place and then the table will be updated.
12
when customer fulfills a payment, the table will be updated by the salesman
inputs: $payment_type, $payment_amount
UPDATE PAYMENTSET payment_type = $payment_type AND remaining_amount =remaining_amount – payment_amount
13
WHERE payment_id = $payment_id
Show Selected Costumers Details and Past Actions
SELECT Booking.booking_no P.payment_status P.remaining_amount A.modelname A.modelyear FROM BOOKING Booking PAYMENT P AUTO AWHERE Booking.customerid = $customer_id AND P.paymentno = Booking.paymentno AND Booking.auto_id = A.autoid
Confirm a reservation as reserved
UPDATE BOOKING BSET B.reservationstatus = “rsrvd”
confirm the payment of a reservation
UPDATE BOOKING BSET B.reservationstatus = “paid”
Add a new branch Inputs: ( $branchid, $branchname, $addressid, $detailedaddress, $phoneno)
INSERT
14
INTO ADDRESS(addressid, detailedaddress)VALUES(‘detailedaddress’, ’addressid’, ’phoneno’)
INSERT INTO BRANCH (branchid,branchname, addressid)VALUES(‘branchid’, ‘branchname’, ‘addressid’)
Add new car to a branchInputs: (‘autoid’, ‘brandname’,’modelyear’, ‘modelname’, ‘autocolor’,’lastbookingno’)
INSERT INTO AUTO (autoid, brandname,modelyear, modelname, autocolor,lastbookingno)VALUES (‘autoid’, ‘brandname’,’modelyear’, ‘modelname’, ‘autocolor’,’lastbookingno’)$autoid = Last index of Autoid
15
Sign up for a new customer
inputs ($name, $age, $address, $TCid, $address, $city, $detailedaddress, $zipcode, $phoneno)variables $customerid : Last index of customerid
INSERT INTO CUSTOMER (customerid, name, age, TCidno)VALUES ($customerid , $name, $age , $TCid)
INSERT INTO PERSON(age, name , TCid)VALUES($age ,$name, $TCid)
INSERTINTO ADDRESS(addressid, city, detailedaddress, zipcode, phoneno)VALUES($address, $city, $detailedaddress, $zipcode, $phoneno)
Delete a car from specific branchinput: $autoid
DELETE FROM AUTOS AWHERE A.autoid = $autoid
16
List all cars
input: $branchidSELECT *FROM AUTO A BRANCH BWHERE B.branchid = A.branchid AND A.branchid = $branchid
List all staff
17
input: $staffid
SELECT *FROM PERSON P BRANCH BWHERE B.branchid = A.branchid AND A.branchid = $branchid
Update car price
input: $newvalue
UPDATE AUTO ASET A.dailyfare = $newvalue
Add a service checkinputs: $autoid$nextcheckdate = previous check date + regular check period$serviceid
SELECT A.autoidFROM AUTO AWHERE A.autoid = $autoid AND
SELECT SC.nextcheckdateFROM SERVICECHECK SC SERVICECHECK SC2WHERE SC.autoid = $autoid AND SC2.serviceid > SC.serviceid
18
INSERTINTO SERVICECHECK(nextcheckdate, serviceid, servicedetail, autoid)VALUES ($nextcheckdate, $serviceid, NULL, $autoid)
Finally we will have a simple login screen which separates the users. According to the given credentials, system will differentiate the customers from branch staffs.
19