Академический Документы
Профессиональный Документы
Культура Документы
(A)
LEXIS CAR RENTALS
LEXIS CAR RENTALS is firm which is into the renting of cars and wants to develop a database
system to monitor its customers, rentals, and their locations.
A car may belong to one vehicle category. Every category is described by a unique ID
number, a label and a detailed description of the category. LEXIS RENTALS has so many
offices in Ghana. Each location has a unique ID number, address (Region, city, number,
street) and more telephone numbers. LEXIS RENTALS also keeps records of its customers in
the database. A customer is described by a unique ID number, SSN, Name (first and Last
name), Region, email, mobile number and the city he or she lives. Customers rent a car,
which they move it from one location to another. A rental is also described by a unique
reservation number, rental amount, a Pickup date and a return date.
ADVANTAGES OF THE DATABASE SYSTEM
a. The DBMS will help the organization to categorize and structure all available data.
Car
Car Type
Reservation
Customer
Rental
LEXIS OFFICES
(B) ENTITY RELATIONSHIP DIAGRAM NORMALISED TO THE 3RD NORMAL FORM
Name Attributes Data Type Value Constraint
-- --------------------------------------------------------
--
-- Table structure for table `car`
--
--
-- Dumping data for table `car`
--
-- --------------------------------------------------------
--
-- Table structure for table `car_type`
--
--
-- Dumping data for table `car_type`
--
INSERT INTO `car_type` (`typeID`, `typeLabel`, `typeDescr`) VALUES
(90, 'sedan', 'has four doors'),
(100, 'sports car', 'sleek and cool'),
(110, 'coupe', 'two doors');
-- --------------------------------------------------------
--
-- Table structure for table `customer`
--
--
-- Dumping data for table `customer`
--
INSERT INTO `customer` (`customerID`, `name`, `city`, `email`, `region`,
`mobile`, `SSN`) VALUES
(700, 'jerry prichard', 'tema', 'jerpr@yahoo.com', 'greater accra', '0245678900',
'JP00567H2'),
(710, 'braun strowman', 'ashaiman', 'brstrow@gmail.com', 'greater accra',
'0202590894', 'BS26756UH'),
(720, 'bruce willis', 'dansoman', 'brwilli@gmail.com', 'greater accra',
'0245678906', 'BR-23457S');
-- --------------------------------------------------------
--
-- Table structure for table `office`
--
--
-- Dumping data for table `office`
--
-- --------------------------------------------------------
--
-- Table structure for table `reservation`
--
--
-- Dumping data for table `reservation`
--
INSERT INTO `reservation` (`reservationID`, `carID`, `customerID`,
`pickuplocationID`, `returnDate`, `pickupDate`, `returnlocationID`, `amount`)
VALUES
(90, 20, 720, 999, '2020-07-07 00:00:00', '2020-07-01 00:00:00', 880,
'7550.00'),
(501, 20, 700, 2000, '2020-07-22 00:00:00', '2020-07-04 00:00:00', 301,
'5000.00'),
(502, 21, 710, 789, '2020-07-20 00:00:00', '2020-07-06 00:00:00', 987,
'4567.00');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `car`
--
ALTER TABLE `car`
ADD PRIMARY KEY (`carID`),
ADD KEY `car_car_type_FK` (`typeID`);
--
-- Indexes for table `car_type`
--
ALTER TABLE `car_type`
ADD PRIMARY KEY (`typeID`);
--
-- Indexes for table `customer`
--
ALTER TABLE `customer`
ADD PRIMARY KEY (`customerID`),
ADD UNIQUE KEY `customer__UN` (`SSN`);
--
-- Indexes for table `office`
--
ALTER TABLE `office`
ADD PRIMARY KEY (`officeID`),
ADD KEY `office_car_FK` (`carID`);
--
-- Indexes for table `reservation`
--
ALTER TABLE `reservation`
ADD PRIMARY KEY (`reservationID`),
ADD KEY `reservation_car_FK` (`carID`),
ADD KEY `reservation_customer_FK` (`customerID`);
--
-- Constraints for dumped tables
--
--
-- Constraints for table `car`
--
ALTER TABLE `car`
ADD CONSTRAINT `car_car_type_FK` FOREIGN KEY (`typeID`) REFERENCES
`car_type` (`typeID`);
--
-- Constraints for table `office`
--
ALTER TABLE `office`
ADD CONSTRAINT `office_car_FK` FOREIGN KEY (`carID`) REFERENCES `car`
(`carID`);
--
-- Constraints for table `reservation`
--
ALTER TABLE `reservation`
ADD CONSTRAINT `reservation_car_FK` FOREIGN KEY (`carID`) REFERENCES
`car` (`carID`),
ADD CONSTRAINT `reservation_customer_FK` FOREIGN KEY (`customerID`)
REFERENCES `customer` (`customerID`);
COMMIT;
1. SELECT carID,typeLabel,brand
from car join car_type
ON car.typeID = car_type.typeID
where color = 'black';
2. SELECT * FROM `car` WHERE carID = 20;
3. SELECT COUNT(customerID) AS customerID,name ,city from customer G
ROUP BY name,city ORDER BY customerID DESC;
4. SELECT brand, address , model from car join office on office.carID = car.c
arID;
5. update car set color = 'red' WHERE color = 'black’;