Auto Mobile DataBase Project
Auto Mobile DataBase Project
Automobile Project
Covered By
Fundamental Database Management System
1
Group – 3
2
Contents
Chapter 1: Introduction
1.1: Project Description
1.2: Project Objectives
Chapter 2: Database Management System
2.1: Entity Relationship (ER) Diagram
2.2: Data Dictionary
2.3: Data Insertion in Relational Tables
2.4: Customer Requirements
2.5: Query Planning with Algebra
2.6: Query Execution with MySQL
Chapter 3: Conclusion
3
Chapter-1
Introduction
1
1.2 Project Objectives
2
Chapter-2
Database Management System
3
4
2.2 Data Dictionary
5
Entity Name: Suppliers
Primary Key: SuppilerID
Foreign Key: -
Attribute Name Data Types Size Description
SuppilerID (PK) VARCHAR 10 Unique Identification Number for
suppliers
SuppilerEmail VARCHAR 30 Supplier email
SuppilerName VARCHAR 30 Names of the supplier
SuppilerPhone VARCHAR 20 Supplier Phone Number
Suppilerlocation VARCHAR 15 Location of the supplier
6
Entity Name: Model
Primary Key: ModelID
Foreign Key: BrandID
Attribute Name Data Types Size Description
ModelID (PK) VARCHAR 10 Unique Identification Number for Model
ModelName VARCHAR 15 Name of the Model
BrandID (FK) VARCHAR 10 Identification Number for Brands
Vehiclestyle VARCHAR 20 The style of the vehicle
CountryOfOrigin VARCHAR 20 Country of origin
7
Entity Name: Purchase
Primary Key: PurchaseID
Foreign Key: CustomerID, DealersID
Attribute Name Data Types Size Description
PurchaseID (PK) VARCHAR 10 Unique Identification Number for Customer
Purchases
CustomerID (FK) VARCHAR 20 Identification Number for Customer
DealersID (FK) VARCHAR 10 Identification Number for Dealer
VehicleID (FK) VARCHAR 10 Identification Number for Vehicle
PurchaseDate DATE - Date on which the purchase is made
PaymentMethod VARCHAR 10 Payment Method for the purchase
Quantity INT - Number of vehicles purchased
TotalPrice INT - Total price of the purchase
8
2.3 Data Insertion in Relational Tables
BrandID varchar(10),
ModelID varchar(10),
VehicleLiscense varchar(15),
ManufactureYear int,
Price int,
);
Insert code
VALUES
('V-1','B-3','M-1','O6-6604',2005,4300000), ('V-2','B-3','M-1','T5-4401',2013,6600000),
('V-3','B-1','M-2','I2-9653',2016,4400000), ('V-4','B-5','M-3','Q9-9887',2009,9100000),
('V-5','B-1','M-4','N6-3555',2005,8000000), ('V-6','B-5','M-5','F9-7178',2017,8300000),
('V-7','B-4','M-6','X5-3831',2020,4500000), ('V-8','B-1','M-7','E2-6149',2009,6900000),
('V-9','B-4','M-8','W9-6118',2006,4800000), ('V-10','B-4','M-9','X3-6935',2001,3700000),
('V-11','B-1','M-10','B2-4402',2013,9500000), ('V-12','B-2','M-11','H9-4994',2020,8800000),
('V-13','B-3','M-2','P1-9115',2011,9700000), ('V-14','B-4','M-9','V9-8123',2013,5300000),
('V-15','B-4','M-11','Z9-7737',2011,8900000),('V-16','B-5','M-5','F4-5841',2004,8700000),
('V-17','B-5','M-7','Z7-3489',2019,4200000), ('V-18','B-1','M-8','G5-7151',2020,6400000),
('V-19','B-5','M-9','L3-7459',2008,8400000),('V-20','B-3','M-10','E4-9840',2002,7400000),
('V-21', 'B-2', 'M-5', 'D9-1234', 2015, 5500000),('V-22', 'B-3', 'M-6', 'E8-5678', 2019, 7000000),
('V-23', 'B-6', 'M-8', 'F7-4321', 2014, 6000000),('V-24', 'B-1', 'M-2', 'G6-8765', 2017, 7500000),
('V-25', 'B-4', 'M-4', 'H5-3456', 2018, 8000000),('V-26', 'B-6', 'M-10', 'J3-9876', 2016, 6500000),
9
('V-27', 'B-2', 'M-11', 'K2-6543', 2017, 9000000),('V-28', 'B-3', 'M-1', 'L1-2345', 2018, 8500000),
('V-29', 'B-5', 'M-7', 'M0-7654', 2019, 9500000), ('V-30', 'B-6', 'M-3', 'N9-8765', 2020, 10000000);
CustomerEmail VARCHAR(45),
CustomerName VARCHAR(55),
CustomerPhone VARCHAR(20),
Gender varchar(10),
Income int
);
Insert code
INSERT INTO Customers (CustomerID, CustomerEmail, CustomerName, CustomerPhone,
Gender, Income) VALUES
('C-1', '[email protected]', 'John Smith', '+1-123-456-7890', 'Male', 500000),
('C-2', '[email protected]', 'Jane Johnson', '+1-234-567-8901', 'Female', 600000),
('C-3', '[email protected]', 'Michael Williams', '+1-345-678-9012', 'Male', 750000),
('C-4', '[email protected]', 'Emily Brown', '+1-456-789-0123', 'Female', 550000),
('C-5', '[email protected]', 'David Jones', '+1-567-890-1234', 'Male', 700000),
('C-6', '[email protected]', 'Sarah Smith', '+1-678-901-2345', 'Female', 600000),
('C-7', '[email protected]', 'John Johnson', '+1-789-012-3456', 'Male', 650000),
('C-8', '[email protected]', 'Jane Williams', '+1-890-123-4567', 'Female', 800000),
('C-9', '[email protected]', 'Michael Brown', '+1-901-234-5678', 'Male', 550000),
('C-10', '[email protected]', 'Emily Jones', '+1-012-345-6789', 'Female', 700000),
('C-11', '[email protected]', 'David Smith', '+1-123-456-7890', 'Male', 600000),
('C-12', '[email protected]', 'Sarah Johnson', '+1-234-567-8901', 'Female', 750000),
('C-13', '[email protected]', 'John Williams', '+1-345-678-9012', 'Male', 550000),
('C-14', '[email protected]', 'Jane Brown', '+1-456-789-0123', 'Female', 700000),
('C-15', '[email protected]', 'Michael Jones', '+1-567-890-1234', 'Male', 600000),
('C-16', '[email protected]', 'Chris', '+1-154-531-8753', 'Male', 75000),
('C-17', '[email protected]', 'Rebacca', '+1-348-967-8759', 'Female', 550000),
('C-18', '[email protected]', 'Jonas', '+1-425-804-2134', 'Male', 700000);
10
Dealer Table Data
DealerEmail varchar(30),
DealerName varchar(30),
DealerPhone varchar(20),
Location varchar(15)
);
Insert code
VALUES
11
Supplier Table Data
SuppilerEmail varchar(30),
SuppilerName varchar(30),
SuppilerPhone varchar(20),
Suppilerlocation varchar(15),
Typesofsupplies varchar(30)
);
Insert code
VALUES
12
Brand Table Data
CompanyID VARCHAR(15),
);
Insert code
VALUES
13
Models Table Data
ModelName varchar(15),
BrandID varchar(10),
Vehiclestyle varchar(20),
CountryOfOrigin varchar(20),
ReleaseYear int,
);
Insert code
('M-11','Bentayga Azure','B-6','SUV','Germany',2015);
14
Options Table Data
Color VARCHAR(20),
EngineModel VARCHAR(40),
FuelType VARCHAR(10),
HorsePower INT,
Transmission VARCHAR(30),
);
Insert code
15
ModelOption Table Data
Primary Key(ModelID,OptionID)
);
Insert code
('M-2', 'O-12'), ('M-2', 'O-3'), ('M-2', 'O-4'), ('M-2', 'O-5'), ('M-3', 'O-11'), ('M-3', 'O-12'),
('M-3', 'O-8'), ('M-3', 'O-4'),('M-3', 'O-15'), ('M-4', 'O-1'),('M-4', 'O-2'), ('M-4', 'O-13'),
('M-4', 'O-4'),('M-4', 'O-5'), ('M-5', 'O-1'),('M-5', 'O-2'), ('M-5', 'O-3'), ('M-5', 'O-6'),
('M-5', 'O-5'), ('M-6', 'O-1'),('M-6', 'O-2'), ('M-6', 'O-3'), ('M-6', 'O-4'), ('M-6', 'O-7'),
('M-7', 'O-14'), ('M-7', 'O-15'), ('M-7', 'O-11'), ('M-8', 'O-9'), ('M-8', 'O-10'), ('M-8', 'O-12'),
('M-10', 'O-10'), ('M-11', 'O-1'), ('M-11', 'O-3'),('M-11', 'O-8'), ('M-11', 'O-10'),('M-11', 'O-13');
16
Companies Table Data
CompanyName VARCHAR(30)
);
Insert code
17
CompanyOwnedManufacturingPlants Table Data
ManufactureID varchar(10),
ManufacturingPlantsName varchar(20),
CompanyID varchar(15),
PlantLocation varchar(30),
);
Insert code
18
DealerPurchase Table Data
VehicleID varchar(10),
DealersID varchar(10),
SupplyTimeInDays int,
Units int,
Primary Key(VehicleID,DealersID)
);
Insert code
VALUES
('V-1', 'D-1', '100', '1'), ('V-2', 'D-2', '60', '1'), ('V-3', 'D-3', '211', '4'),
('V-4', 'D-4', '156', '2'), ('V-5', 'D-5', '90', '2'), ('V-6', 'D-4', '75', '1'),
('V-7', 'D-3', '78', '2'), ('V-8', 'D-2', '30', '1'), ('V-9', 'D-1', '98', '2'),
('V-10', 'D-5', '69', '1'), ('V-11', 'D-1', '166', '1'), ('V-12', 'D-2', '249', '5'),
('V-13', 'D-3', '101', '2'), ('V-14', 'D-4', '57', '1'), ('V-15', 'D-4', '109', '4'),
('V-16', 'D-5', '39', '1'), ('V-17', 'D-4', '244', '3'), ('V-18', 'D-1', '10', '1'),
('V-19', 'D-2', '40', '1'), ('V-20', 'D-2', '18', '1'), ('V-21', 'D-3', '158', '1'),
('V-22', 'D-4', '183', '8'), ('V-23', 'D-5', '203', '1'), ('V-24', 'D-5', '91', '1'),
('V-25', 'D-1', '105', '7'), ('V-26', 'D-4', '55', '1'), ('V-27', 'D-3', '69', '1'),
('V-28', 'D-5', '122', '2'), ('V-29', 'D-4', '198', '3'), ('V-30', 'D-3', '287', '5');
19
Purchase Table Data
PurchaseID varchar(10),
CustomerID VARCHAR(20),
DealersID varchar(10),
VehicleID varchar(10),
PurchaseDate Date,
PaymentMethod varchar(10),
Quantity INT,
TotalPrice int,
Primary key(PurchaseID),
);
Insert code
20
('P-10', 'C-10', 'D-5', 'V-10', '2020-02-25', 'credit cards', 1, 3700000),
21
ManufacturedBrand Table Data
Manufacture_ID varchar(10) ,
BrandID varchar(10) ,
SuppilerID varchar(10) ,
SupplyDate Date
);
Insert code
INSERT INTO Manufactured_Brand (ManufacturedBrandID, Manufacture_ID, BrandID,
SuppilerID, SupplyDate) VALUES
('MB1', '1GN', 'B-1', 'S-1', '2020-01-01'),
('MB2', 'SVS', 'B-6', 'S-3', '2022-02-15'),
('MB3', 'JHM', 'B-4', 'S-7', '2020-03-10'),
('MB4', '1GN', 'B-3', 'S-4', '2021-04-05'),
('MB5', 'SVS', 'B-5', 'S-7', '2022-05-20'),
('MB6', 'JHM', 'B-1', 'S-3', '2020-06-15'),
('MB7', 'WBA', 'B-2', 'S-6', '2020-07-10'),
('MB8', 'JHM', 'B-3', 'S-2', '2021-08-25'),
('MB9', 'SVS', 'B-5', 'S-1', '2022-09-30'),
('MB10', 'WBA', 'B-2', 'S-4', '2023-10-15');
22
2.4 Customer Requirement
1. Show sales trends for various brands over the past 3 years, by year, month, week. Then
break these data out by gender of the buyer and then by income range.
2. Suppose that it is found that transmissions made by supplier Getrag between two given
dates are defective. Find the VIN of each car containing such a transmission and the
customer to which it was sold. If your design allows, suppose the defective
transmissions all come from only one of Getrag’s plants.
6. Find those dealers who keep a vehicle in inventory for the longest average time.
23
2.5 Query Planning with Algebra
Algebra 1: π sales trends (𝜎 purchaseDate = 2020 and purchaseDate = 2021 and purchaseDate = 2022
and count(gender)=maximum (Customers ⨝ Purchase ⨝ Vehicle));
Algebra 2:
Q1=σsuppilerName=′Getrag′∧SupplyDate between ′2020−1−1′ and ′2023−1−1′(Suppliers ⨝ Manufactured_brand)
Q2=Vehicle ⨝ purchase
Temp=Q1 ⨝Q1.VehicleLiscense=Q3.VehicleLiscense Q3
Result=Temp ⨝ Q2
Final=πQ2.CustomerName, Q1.SupplyDate,Q1.VehicleLiscense,min(Q3.Transmission)(Result)
Algebra 3: π vin of each car (𝜎 supplier-name = “Getrag” (Vehicle ⨝ Supplier ⨝ ManufacturedBrand)):
Algebra 5: π months (𝜎 convertibles = 1 and year = 2020 and year = 2021 and year = 2022(Purchase X
Vehicle ⨝ Model-option ⨝ Options));
24
Query 1
Select BrandName,year(PurchaseDate),month(PurchaseDate),week(PurchaseDate),Gender,Income
from Customers
join vehicle on
purchase.VehicleID = vehicle.VehicleID
Outcome
25
Query 2
Input
SELECT
FROM
FROM Suppliers AS SP
) AS Q1
INNER JOIN
FROM Vehicle V
LEFT JOIN
FROM Vehicle
) AS Q2 ON Q1.VehicleLiscense = Q2.VehicleLiscense
Outcome
26
Query 3
Input
Select BrandName, TotalPurchase
From
(
Select BrandName, sum(TotalPrice) as TotalPurchase
From Brands, Vehicle, Purchase
Group by BrandName
Order By TotalPurchase desc
Limit 2
)
As TopBrands;
Outcome
27
Query 4
Input
Select BrandName, TotalUnitSales
From
(
Select BrandName, Sum(Quantity) as TotalUnitSales
From Brands, Vehicle, Purchase
Group by BrandName
Order by TotalUnitSales desc
Limit 2
)
As TopBrands ;
Outcome
28
Query 5
Input
SELECT
MONTH(P.PurchaseDate) AS Month,
COUNT(MONTH(P.PurchaseDate)) AS ConvertibleCount
FROM
Purchase AS P
JOIN
JOIN
JOIN
WHERE
O.Convertible = 1
GROUP BY
MONTH(P.PurchaseDate)
limit 1;
Outcome
29
Query 6
Input
SELECT Dealername, ROUND(AVG(sumdate)) AS Average_Days
FROM (
FROM dealers
) AS Result
GROUP BY Dealername
30
Chapter-3
Conclusion
This project aims to create a relational database system for an Automobile Company,
and to have functionality to address and solve specific requirements and problems for
specific situations. From the entities and queries to how the ERD will be constructed, the
aim, vision and planning was a crucial part of the project.
Looking at the finished project, it can be safe to say that the aims and requirements
have come to fruition. After the planning of the ERD and the creation of entities, the
requested queries and requirements were able to be executed with minimal adjustment to
the database, showing that the system is flexible and made to accommodate different
scenarios.
The process of the coding and development of the database itself was made with care
and caution. Each member did their assigned role, and their work was constantly under
review and feedback by fellow team members, creating a more usable, standardized result.
The work was also coordinated and efficient, making use of cloud-based word processing
software to record and document the tasks of each member. Whether in person or online,
discussions were common, proving the members’ enthusiasm to see a great finalized
product.
Arguably the most important part of a project after most of it has finished is the
documentation of the project itself. This was kept in mind during all stages of the project,
by use of the previously mentioned word software as well as the topic of documentation
being a common point of discussion in meetings. In this final document, care is given to
document every aspect of it and in a clear, concise way. No standard was dropped in the
writing of the data dictionary, query list, output preview, relational algebra and so on,
creating a report that helps not only people involved in the project, but also anyone that
might take an interest.
All in all, the project can be rounded up to a success. While we face minor issues in
the planning and design phase of the database, they were quickly dealt with and discussed
over. The finished project can fulfill the requirements and queries imposed upon it, and it is
our confident hope that it can also meet any future challenges it might face.
31