This project models an Online Cab Reservation System using a Star Schema for Dimensional Modeling. The database design focuses on analyzing reservations, driver performance, customer data, and more. The system is implemented in MySQL.
The ER Diagram represents the entities involved in the cab reservation system and their relationships.
The Star Schema comprises a central fact table surrounded by dimension tables, ideal for reporting and analytics.
-
Fact Table:
FactReservation
: Contains transactional data related to cab reservations, such as fare, distance, and duration.
-
Dimension Tables:
DimensionCustomer
: Information about customers.DimensionDriver
: Driver details.DimensionCab
: Cab-related data.DimensionLocation
: Data about pickup and drop-off locations.DimensionDate
: Date information.DimensionTime
: Time-related data for reservations.
-
DimensionCustomer
CustomerID
: Primary key.CustomerName
,CustomerEmail
,CustomerPhone
,CustomerAddress
: Information about customers.
-
DimensionDriver
DriverID
: Primary key.DriverName
,DriverPhone
,DriverLicenseNumber
,DriverRating
: Driver information.
-
DimensionCab
CabID
: Primary key.CabModel
,CabNumber
,CabType
,CabCapacity
: Cab data.
-
DimensionLocation
LocationID
: Primary key.LocationName
,LocationAddress
,City
,State
,Country
: Location details.
-
DimensionDate
DateID
: Primary key.Day
,Month
,Year
,Quarter
: Date-related attributes.
-
DimensionTime
TimeID
: Primary key.Hour
,Minute
,Second
: Time of reservation.
- FactReservation
ReservationID
: Primary key.CustomerID
,DriverID
,CabID
,DateID
,TimeID
,PickupLocationID
,DropoffLocationID
: Foreign keys.FareAmount
,DistanceTraveled
,Duration
: Transactional data of each reservation.
Below are some complex SQL queries to extract insights from the system:
SELECT
d.DriverName,
SUM(f.FareAmount) AS TotalRevenue
FROM
FactReservation f
JOIN
DimensionDriver d ON f.DriverID = d.DriverID
GROUP BY
d.DriverName
ORDER BY
TotalRevenue DESC;
SELECT
d.Month,
COUNT(f.ReservationID) AS TotalReservations
FROM
FactReservation f
JOIN
DimensionDate d ON f.DateID = d.DateID
GROUP BY
d.Month
ORDER BY
d.Month;
SELECT
c.CabType,
AVG(f.Duration) AS AverageTripDuration,
AVG(f.FareAmount) AS AverageFare
FROM
FactReservation f
JOIN
DimensionCab c ON f.CabID = c.CabID
GROUP BY
c.CabType
ORDER BY
AverageTripDuration;
SELECT
l1.LocationName AS PickupLocation,
l2.LocationName AS DropoffLocation,
COUNT(f.ReservationID) AS NumberOfTrips
FROM
FactReservation f
JOIN
DimensionLocation l1 ON f.PickupLocationID = l1.LocationID
JOIN
DimensionLocation l2 ON f.DropoffLocationID = l2.LocationID
GROUP BY
l1.LocationName, l2.LocationName
ORDER BY
NumberOfTrips DESC;
- MySQL or Oracle database installed on your system.
-
Clone this repository:
git clone https://github.com/your-username/online-cab-reservation-system.git
-
Import the SQL file provided to create the database schema:
- Open MySQL Workbench (or any database tool) and import the script to create the tables and insert sample data.
-
Connect your MySQL Workbench or Oracle client to the database.
- Run the provided SQL queries in MySQL Workbench or Oracle SQL Developer to generate insights and reports.
- Modify the schema or queries based on your specific use cases or data requirements.
This project is licensed under the MIT License. See the LICENSE file for more details.
### Key Notes:
- Replace `link_to_your_er_diagram_image` with the correct path to the ER diagram image.
- Change `your-username` in the repository URL to your GitHub username.
This `README.md` gives an overview of the project, including schema design, installation, queries, and usage instructions.