Database Design and Implementation for a Vehicle Service Business - Desklib
Verified
Added on 2023/05/28
|21
|5533
|240
AI Summary
The proposed case study is for a vehicle service business that needs a database system to shift from manual methods. Learn about the logical database design and oracle SQL implementation for the business. Get insights on creating tables, indexes, and data population.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
COVER PAGE
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Contents Case study...................................................................................................................................................3 Conceptual design.......................................................................................................................................4 EER Diagram............................................................................................................................................4 Enterprise rules.......................................................................................................................................4 Logical database design and oracle SQL implementation/querying........................................................4 Logical database design...........................................................................................................................4 Creating tables using oracle DBMS..........................................................................................................7 Create indexes.......................................................................................................................................12 Data population.....................................................................................................................................12 Query Writing........................................................................................................................................19
Case study The proposed case study is for a vehicle service business. The vehicle service business is in need of a database system that will help it to shift from the manual methods that are currently in use by the business. The normal business process of the business involves customers making calls to make appointments for booking vehicle repair services. The business provides different types of services and a customer can book an appointment for one or more services. On booking for a service, the business maintains customer records to make it easier to identify new and existing customers. Customer records are kept in a spreadsheet located in the business’s only computer. The appointments made by the customers are recorded in post cards. The business also maintain staff records of all the staff members working at the business premises. For each staff, a set of qualifications is recorded. The qualifications include the services that the staff can perform. Each service booked for in an appointment is taken care of by a number of staff who are qualified to perform that service on the vehicle. After the service is done, the staff can write some notes concerning the service and the status of the service is updated to complete. After all services booked for a specific appointment are completed, the customer can proceed to make the payment using any of the preferred payment methods accepted by the business. The car is then released to the customer and the release date is recorded. The payment done for an appointment is supposed to be paid in full installments and the customer is not allowed to have a balance before the vehicle is released. The business is finding it hard to manage all this information using spreadsheets and documents since it’s very tedious to track and manage the data for report generation. For this reason, the business believes that a well-designed database system can be a solution to all their problems and will help them run the business more efficiently. Assumptions The case study is specified based on the following assumptions; A customer makes appointments for services that are offered at the business. The customer cannot make an appointment for a service not offered by the business. The customer has to drop their car after making an appointment and pick their car at the business premises after the car has been fully serviced. The customer cannot pick their car if they have not paid total money accrued as a result of servicing their vehicle. The payment should be a one of payment and should only use one payment method accepted by the business.
Conceptual design EER Diagram Enterprise rules The EER Diagram models the following enterprise rules; A car owner can own one or more cars. A car can only be owned by one and only one car owner. A car can be scheduled for one more appointments. An appointment is made for one or more services. Each of the services making an appointment must be offered by the business. A staff has one or more qualifications. A qualification by a staff is for one and only one service. An appointment is dealt with by one or more staff. An appointment results to one and only one payment. A payment can only be done using one and only one payment method accepted by the business. Logical database design and oracle SQL implementation/querying Logical database design The following tables derived from the EER Diagram will make up the database. CAR_OWNERS Column NameKeyNull/Not NullTypeDescription
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
OwnerIDPrimary keyNot nullIntegerUnique primary key that will be used to identify each car owner firstNameNot nullVarchar2(50)First name of the car owner lastNameNot nullVarchar2(50)Last name of the car owner phoneNONot nullVarchar2(25)The phone number of the car owner emailNot nullVarchar2(100)The email of the car owner through which the business can reach him through STAFF Column NameKeyNull/Not NullTypeDescription staffIDPrimary keyNot nullIntegerUnique primary key that will be used to identify each staff firstNameNot nullVarchar2(50)First name of the staff lastNameNot nullVarchar2(50)Last name of the staff addressNot nullVarchar2(25)The address of the staff. It should include the street and the posal code emailNot nullVarchar2(100)The email of the taff through which the business can reach him through phoneNONot nullVarchar2(25)Phone number of the staff STAFF_QUALIFICATIONS Column NameKeyNull/Not NullTypeDescription StaffIDPrimary key Foreign key references Staff (StaffID) Not nullIntegerPart of the composite primary key used to identify a staff qualification. It’s also a foreign key referencing a certain staff serviceIDPrimary key Foreign key references service (serviceID Not nullintegerPart of the composite primary key used to identify a staff qualification. It’s also a foreign key referencing a certain service SERVICE Column NameKeyNull/Not NullTypeDescription serviceIDPrimary keyNot nullIntegerUnique primary key that will be used to identify each service offered by the business TypeNot nullVarchar(50)The type of the service NameNot nullVarchar(50)Name used to identify the service PriceNot nulldecimalThe price charged to conduct the service CAR
Column NameKeyNull/Not NullTypeDescription carIDPrimary keyNot nullIntegerUnique primary key that will be used to identify each car regNONot nullVarchar(50)The official registration number of the car modelNot nullVarchar(50)The model of the car for example Mercedes Benz typeNot nullVarchar(50)The type of the car for example sedan ownerIDForeign key references car_owner(ownerID ) Not nullintegerThe owner of the car. This is the foreign key that references the unique ownerID who owns the car APPOINTMENT Column NameKeyNull/Not NullTypeDescription AppointmentIDPrimary keyNot nullIntegerUnique primary key that will be used to identify each appointment carIDForeign key referencing car (carID) Not nullIntegerForeign key referencing the specific car for which the appointment is meant for appointmentDateNot nullDateThe date the car is booked for service releaseDatenullDateThe date the car is released and picked by the customer APPOINTMENT_SERVICES Column NameKeyNull/Not NullTypeDescription AppointmentIDPrimary key Foreign key referencing appointment (appointmentID) Not nullIntegerPart of the composite primary key used to identify a specific appointment service. Its also the foreign key referencing the specific appointment serviceIDPrimary key Foreign key referencing Service (serviceID) Not nullIntegerPart of the composite primary key used to identify a specific appointment service. This is also a foreign key referencing the specific service notesVarchar2(500)Notes taken by the staff regarding the service of the vehicle for the specific service statusNot nullVarchar2(15)The status of the job. It can either be complete or pending. APPOINTMENT_STAFF Column NameKeyNull/Not NullTypeDescription
AppointmentIDPrimary key Foreign key referencing appointment (appointmentID) Not nullIntegerPart of the composite primary key used to identify a specific appointment service. Its also the foreign key referencing the specific appointment StaffIDPrimary key Foreign key referencing staff (staffID) Not nullIntegerPart of the composite primary key used to identify a specific staff. It’s also a foreign key referencing the specific staff working on the appointment PAYMENT Column NameKeyNull/Not NullTypeDescription PaymentIDPrimary keyNot nullIntegerUnique primary key that will be used to identify each payment appointmentIDForeign key referencing Appointment (AppointmentID) Not nullIntegerForeign key referencing the specific appointment for which the payment is being made for PaymentDateNot nullDateThe date the payment is made amountNot nullDecimalThe total amount paid methodIDForeign key referencing Payment_Method (MethodID) Not nullIntegerForeign key used to reference the method used to make payment PAYMENT_METHOD Column NameKeyNull/Not NullTypeDescription MethodIDPrimary keyNot nullIntegerUnique primary key that will be used to identify each payment method nameNot nullVarchar2(50)The name of the payment method for example cash. Creating tables using oracle DBMS create table car_owners( ownerID integer primary key, firstName varchar2(50) not null, lastName varchar2(50) not null, phoneNo varchar2(25) not null, email varchar2(100) not null
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
); create table staff( staffID integer primary key, firstName varchar2(50) not null, lastName varchar2(50) not null, address varchar2(100) not null, email varchar2(100) not null, phoneNo varchar2(25) not null ); create table service ( serviceID integer primary key, type varchar2(50) not null, name varchar2(50) not null, price decimal not null );
create table staff_qualifications( staffID integer not null, serviceID integer not null, primary key (staffID,serviceID), Foreign key (staffID) references staff (staffID), Foreign key (serviceID) references service (serviceID) ); create table car ( carID integer primary key, regNO varchar2(50) not null, model varchar2(50) not null, type varchar2(50) not null, ownerID integer not null, foreign key (ownerID) references car_owners (ownerID) ); create table appointment (
appointmentID integer primary key, carID integer not null, appointmentDate date not null, releaseDate date null, foreign key (carID) references Car (carID) ); create table appointment_services( appointmentID integer not null, serviceID integer not null, notes varchar2(500) null, status varchar2(15) not null, primary key (appointmentID,serviceID), Foreign key (appointmentID) references appointment (appointmentID), Foreign key (serviceID) references service (serviceID) ); create table appointment_staff( appointmentID integer not null, staffID integer not null, primary key (appointmentID,staffID),
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Foreign key (staffID) references staff (staffID), Foreign key (appointmentID) references appointment (appointmentID) ); create table payment_method( methodID integer primary key, name varchar2(50) not null ); create table payment ( paymentID integer primary key, appointmentID integer not null, paymentDate date not null, amount decimal not null, methodID integer not null, foreign key (methodID) references payment_method (methodID) );
Create indexes The following are the most important indexes to the database based on the type of queries to be written; Payment_method (name) index create index payment_method_indexonpayment_method(name); This index is created for the payment_method table for the name column. This index is important to the database because it will be helpful in determining the most preferred payment method by customers. Appointment_services (status) create index appointment_services_indexon appointment_services(status); This index is created for the appointment_services table specifically for the status column. It will be helpful for the database especially in writing a query to determine which appointments are completed and which ones are still pending. Appointment(appointmentDate) create index appointments_index on appointment(appointmentDate); This index is created for the appointment table for the appointmentDate column. This index will be useful especially for the queries that is needed to sort the appointments by the date the appointment was made and this can also be used to limit the result of the appointments based on the appointment date. Service(type) create index service_index on service(type); This index is created for the service table on the type column. This index will be useful to the database when writing a query to get the service type that has the most bookings thus this can be useful in knowing which service type generates the most money for the business. Data population -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- CAR_OWNERS TABLE -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - insert into car_owners (ownerID, firstname, lastname, phoneno, email) values (1 , 'Peter' , 'McKnight' , '+42434453223' , 'peter@mail.com'); insert into car_owners (ownerID, firstname, lastname, phoneno, email) values (2 , 'Lucy','Clarkson', '+42434453223','lucy@mail.com'); insert into car_owners (ownerID, firstname, lastname, phoneno, email) values (3,'Lee','Deakins','+34534434','lee@mail.com');
select model,type from car where type like '%SUV%'; This query is used to get all cars that are of type SUV. The query gets the model of the car and the type of the car for every car that is an SUV. Query 2 select firstname,lastname from staff where staffID not in (select staffID from appointment_Staff); This query is used to get all staff that have never worked on an appointment. Query 3 select firstname,lastname,name from staff inner join staff_qualifications on staff_qualifications.staffID=staff.staffID inner join service on service.serviceID=staff_qualifications.serviceID;
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
This query is used to show all the staff and the service that each staff is qualified to perform. Since a staff can be an expert in one or more services, the query shows all qualifications for a staff. Query 4 select sum(amount) from payment where methodID=(select methodID from payment_method where name='cash'); This query is used to show the total amount of money paid using cash. Query 5 select car.type,car.model,appointment.appointmentDate from car inner join appointment on car.carID=appointment.appointmentID order by appointment.appointmentDate desc;
This query shows all the cars that have been booked for an appointment and the appointment dates the car were booked for. The list is ordered in descending order of the appointment date thus it shows the latest car to be booked for an appointment up to the earliest car booked for an appointment. Query 6 select firstname,lastname,appointmentDate from staff left outer join appointment_staff on staff.staffID=appointment_staff.staffID inner join appointment on appointment_staff.appointmentID=appointment.appointmentID; This query shows all the staff and their appointment dates. For every staff, the appointment dates for which the staff is booked to perform a certain service is shown in the query.