Sei sulla pagina 1di 7

Project: A Car Hire Service Database.

Project Specification:

This project is about computerizing and manual – based Car Hire


Service Company. The main objective for computerizing the processes
of the company would be to minimize massive paperwork that is
involved and the associated costs, amongst other risks associated with
such a system (manual).

This project will consist of a database with Twelve (12) entities


namely: Cars, Hires, Clients, Car Owners, Car Classes, Hire Rates,
Drivers, Inventory Forms, Car Expenses, Receivables, Car Owner
Payments, and Employees.

The database used in this project is MySQL Version 5.0. The entities’
designs are as follows:

The Table Designs:

Receivables Employees Inventory Forms Hires


Trans id Employee id Form id Hire id
Drivers
Car id (fk) Full names Hire id (fk) Car id (fk)
Driver
Clientidid (fk) Dt Employed
Clients Client id (fk) Client id (fk)
Owner
National
Hire id id
(fk) Designation Car id (fk) Rate id (fk)
Client id Payments
num
Employee id (fk) Genderid num Employee Driver id (fk)
National Payment id id (fk)
Full names
Date DoB Mechanical Employee id (fk)
Full names Owner id (fk)
DLAmount
num
DLNational
Num id num Conditionid (fk)
Employee Inventory id (fk)
DLBalance
Hireexpiry
Rates dt Home Address Car Hire Date
Gender Car idbody
Rate id Home Phone
Residence Car
Amountlamps
Class id (fk) Cell Phone
Address Date interior
Car Cars
Rate per day Work Phone Car tyres
Period Car id
Cell Phone Notables
Car Classes Class id (fk)
Referee name Owner id (fk)
Class id Car Expenses
Referee ID num Make
Description Car id
Owners
Referee phone Expense Model
Vehicle types Owner id
Description Body type
Car idNational id num Engine num
Date Full names Chasis num
AmountAddress
Manufacture
Phoneidnum
Employee (fk) yr
Relational Model:

Car
Expenses
Expense id
Car id
Employee
id

Car Owners
Owner id
A relational model showing all the relationships between the various
entities

Entity Relationship Diagram:


m
Car

approve
overs m
ee
approves m
m Inventory Forms
1 1
1 m
Employe 1 1
1

in
fo

fo
r

fo
1

r
from Clients
approve

m
m 1
Receiva
s

1
m m m

in
from 1 Hires
m m
1 1 1 in
from 1 m
1 Cars m

used
m m m
m
fo
r

Owner

in
1
m
Hire
belon
own

1
1
g

Drivers
receiv

fo

m 1
r
e

1 Owners Car 1

SQL Codes:

1. Cars Table:
CREATE TABLE `car_hire`.`cars` (
`car_id` INTEGER UNSIGNED NOT NULL,
`reg_num` VARCHAR(45) NOT NULL,
`class_id` VARCHAR(45) NOT NULL,
`owner_id` VARCHAR(45) NOT NULL,
`make` VARCHAR(45) NOT NULL,
`model` VARCHAR(45) NOT NULL,
`body_type` VARCHAR(45) NOT NULL,
`engine_num` VARCHAR(45) NOT NULL,
`chasis_num` VARCHAR(45) NOT NULL,
`manufacture_yr` VARCHAR(45) NOT NULL,
`color` VARCHAR(45) NOT NULL,
PRIMARY KEY (`car_id`)
)
ENGINE = InnoDB;

2. Clients:

CREATE TABLE `car_hire`.`clients` (


`client_id` INTEGER UNSIGNED NOT NULL,
`national_id_num` VARCHAR(45) NOT NULL,
`fullnames` VARCHAR(100) NOT NULL,
`dl_num` VARCHAR(45) NOT NULL,
`gender` VARCHAR(45) NOT NULL,
`residence` VARCHAR(45) NOT NULL,
`address` VARCHAR(45) NOT NULL,
`workphone` VARCHAR(45) NOT NULL,
`cellphone` VARCHAR(45) NOT NULL,
`referee_name` VARCHAR(100) NOT NULL,
`referee_id_num` VARCHAR(45) NOT NULL,
`referee_phone` VARCHAR(45) NOT NULL,
PRIMARY KEY (`client_id`)
)
ENGINE = InnoDB;

3. Hires:

CREATE TABLE `car_hire`.`hires` (


`hire_id` INTEGER UNSIGNED NOT NULL,
`car_id` INTEGER UNSIGNED NOT NULL,
`client_id` INTEGER UNSIGNED NOT NULL,
`hire_date` DATETIME NOT NULL,
`driver_id` INTEGER UNSIGNED NOT NULL,
`rate_id` INTEGER UNSIGNED NOT NULL,
`inventroy_form_id` INTEGER UNSIGNED NOT NULL,
`employee_id` INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (`hire_id`)
)
ENGINE = InnoDB;

4. Inventory Forms:

CREATE TABLE `car_hire`.`inventory_forms` (


`form_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`hire_id` INTEGER UNSIGNED NOT NULL,
`client_id` INTEGER UNSIGNED NOT NULL,
`car_id` INTEGER UNSIGNED NOT NULL,
`mechanicals` VARCHAR(45) NOT NULL,
`car_body` VARCHAR(45) NOT NULL,
`car_lamps` VARCHAR(45) NOT NULL,
`car_interior` VARCHAR(45) NOT NULL,
`car_tyres` VARCHAR(45) NOT NULL,
`notables` VARCHAR(45) NOT NULL,
`employee_id` INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (`form_id`)
)
ENGINE = InnoDB;

5. Drivers:

CREATE TABLE `car_hire`.`drivers` (


`driver_id` INTEGER UNSIGNED NOT NULL,
`national_id_num` INTEGER UNSIGNED NOT NULL,
`full_names` VARCHAR(100) NOT NULL,
`dl_number` VARCHAR(45) NOT NULL,
`dl_expiry_dt` DATETIME NOT NULL,
PRIMARY KEY (`driver_id`)
)
ENGINE = InnoDB;
6. Receivables:

CREATE TABLE `car_hire`.`receivables` (


`transaction_id` INTEGER UNSIGNED NOT NULL,
`recvd_date` DATETIME NOT NULL,
`amount` INTEGER UNSIGNED NOT NULL,
`car_id` INTEGER UNSIGNED NOT NULL,
`client_id` INTEGER UNSIGNED NOT NULL,
`hire_id` INTEGER UNSIGNED NOT NULL,
`employee_id` INTEGER UNSIGNED NOT NULL,
`balance` INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (`transaction_id`)
)
ENGINE = InnoDB;

7. Car Owners:

CREATE TABLE `car_hire`.`car_owners` (


`owner_id` INTEGER UNSIGNED NOT NULL,
`national_id_num` INTEGER UNSIGNED NOT NULL,
`full_names` VARCHAR(100) NOT NULL,
`address` VARCHAR(45) NOT NULL,
`phone` VARCHAR(45) NOT NULL,
PRIMARY KEY (`owner_id`)
)
ENGINE = InnoDB;

8. Car Class:

CREATE TABLE `car_hire`.`car_class` (


`class_id` INTEGER UNSIGNED NOT NULL,
`description` VARCHAR(45) NOT NULL,
`vehicle_type` VARCHAR(45) NOT NULL,
PRIMARY KEY (`class_id`)
)
ENGINE = InnoDB;

9. Car Owner Payments:

CREATE TABLE `car_hire`.`owner_payments` (


`payment_id` INTEGER UNSIGNED NOT NULL,
`amount` INTEGER UNSIGNED NOT NULL,
`payment_dt` DATETIME NOT NULL,
`owner_id` INTEGER UNSIGNED NOT NULL,
`car_id` INTEGER UNSIGNED NOT NULL,
`period` VARCHAR(45) NOT NULL,
`employee_id` INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (`payment_id`)
)
ENGINE = InnoDB;

10. Hire Rates:


CREATE TABLE `car_hire`.`hire_rates` (
`rate_id` INTEGER UNSIGNED NOT NULL,
`rate_per_day` INTEGER UNSIGNED NOT NULL,
`class_id` INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (`rate_id`)
)
ENGINE = InnoDB;

11. Employeees:

CREATE TABLE `car_hire`.`employees` (


`emplyee_id` INTEGER UNSIGNED NOT NULL,
`full_names` VARCHAR(100) NOT NULL,
`date_employed` DATETIME NOT NULL,
`designation` VARCHAR(45) NOT NULL,
`gender` VARCHAR(45) NOT NULL,
`dt_of_birth` DATETIME NOT NULL,
`nationa_id_num` INTEGER UNSIGNED NOT NULL,
`home_address` VARCHAR(45) NOT NULL,
`home_phone` VARCHAR(45) NOT NULL,
`cell_phone` VARCHAR(45) NOT NULL,
PRIMARY KEY (`emplyee_id`)
)
ENGINE = InnoDB;

12. Car Expenses:

CREATE TABLE `car_hire`.`car_expenses` (


`expense_id` INTEGER UNSIGNED NOT NULL,
`description` VARCHAR(45) NOT NULL,
`car_id` INTEGER UNSIGNED NOT NULL,
`expense_date` DATETIME NOT NULL,
`amount` VARCHAR(45) NOT NULL,
`employee_id` INTEGER NOT NULL,
PRIMARY KEY (`expense_id`)
)
ENGINE = InnoDB;

Potrebbero piacerti anche