221FJ01071 - DBMS Ieee

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Data Base Management System

II BCA I Semester (2023-24)


Department of Information Technology,
Vignan's Foundation for Science, Technology & Research (Deemed to be University),
Guntur, Andhra Pradesh, India

221FJ01071- Suraj Kumar Singh

such as distance, ride type, and any additional


charges.
Title : Ride-Sharing System or Carpooling Platform
8. Passengers should be able to rate drivers
1. Question :- after completing a ride, and drivers should be
Objective : The objective of this case study is able to rate passengers as well.
to design a real-time ride-sharing system. The 9. The system should maintain a history of
system will connect passengers with drivers in past rides for both passengers and drivers.
real-time, allowing them to request and
provide rides efficiently. The real-time ride- 10. The system should have an admin panel to
sharing system aims to provide a platform manage user accounts, handle complaints, and
where passengers can request rides and drivers monitor system performance.
can offer their services. The system will match Tasks:
passengers with available drivers based on
their location, preferences, and availability. a) Identify Entity sets and design an E-R
schema for this application.
Requirements:
b) Specify key attributes of each entity type,
1. The system should support multiple users, attribute type and structural constraints on
including passengers and drivers. each relationship type.
2. Passengers should be able to create c) Based on the Designed E-R Diagram,
accounts, log in, and manage their personal design corresponding Schema Diagram
information.
d) Discuss any assumptions you made and
3. Passengers can request a ride by specifying justify your E-R design choices.
their pick-up location, destination, and
preferred ride type (e.g., economy, premium, e) Create the tables & implement Primary
etc.). keys, Foreign keys for the above scenario.
4. Drivers can create accounts, log in, and f) Insert related data into the above created
manage their personal information, including tables accordingly.
their vehicle details.
5. Drivers should be able to update their
availability status (e.g., available, 2. Abstract:
unavailable). This case study outlines the creation of a real-
6. The system should have real-time tracking time ride-sharing system, aiming to seamlessly
functionality to track the location of drivers connect passengers and drivers for efficient
and transportation. The system facilitates user
registration, ride requests, driver availability
display it to passengers during the ride. updates, fare estimation, real-time tracking,
and user ratings. An admin panel ensures
7. The system should calculate and display the
effective management. The design employs an
estimated fare for each ride, based on factors
Entity-Relationship schema, identifying
entities, attributes, and relationships, UserID (Primary Key)
culminating in a Schema Diagram.
Username
Assumptions align with industry practices.
Implementation includes table creation, Password
primary and foreign keys, and data insertion.
This system innovatively addresses First Name
contemporary transportation needs.. Last Name
3. Introduction: Email
The proliferation of urbanization has brought Phone
forth transportation challenges like traffic
congestion and environmental degradation. In Role (Passenger/Driver)
response, ride-sharing systems have emerged  Passenger :
as a promising solution. This case study delves
into the design of a real-time ride-sharing PassengerID (Primary Key, Foreign Key
system, aiming to connect passengers with referencing User)
drivers efficiently. The system's core UserID
objectives encompass user registration, ride
requests, real-time tracking, fare calculation, Address
and user feedback. Employing Entity-  Driver :
Relationship modeling, the study outlines the
system's architecture, including key entities, DriverID (Primary Key, Foreign Key
attributes, and relationships. By doing so, the referencing User)
study contributes to the discourse on
Vehicle Type
innovative transportation solutions, catering to
the demands of modern urban living. Vehicle Plate Number
Availability Status
(Available/Unavailable)
4. SOLUTION :-
 Ride :
a) Entity-Relationship (E-R) Schema RideID (Primary Key)
Design:
 Entities :- PassengerID (Foreign Key referencing
Passenger)
User (Generalization of Passenger and
Driver) DriverID (Foreign Key referencing Driver)

Passenger Pickup Location

Driver Destination

Ride Ride Type (e.g., economy, premium)

RideType Ride Status


(Requested/Ongoing/Completed)
Rating
Fare Amount
b) Specify key attributes of each entity
type, attribute type  Rating :
RatingID (Primary Key)
RatedUserID (Foreign Key referencing
User, either Passenger or Driver)
 Attributes:
 User :
RatedByUserID (Foreign Key referencing The Rating entity allows both passengers
User, either Passenger or Driver) and drivers to rate each other after a
completed ride.
Rating Value (Numeric value representing
the rating) e) Table Creation and Primary/ Foreign
Keys:
c) Relationship :-
 User :-
CREATE TABLE Users (
Relationships:
UserID INT PRIMARY KEY,
Username VARCHAR(55),
User-Passenger (One-to-One)
Password VARCHAR(55),
One User can be associated with one
Passenger. FirstName VARCHAR(55),

 User-Driver (One-to-One) LastName VARCHAR(55),

One User can be associated with one Driver. Email VARCHAR(55) UNIQUE,

 Driver-Vehicle (One-to-One) Phone VARCHAR(20),

One Driver can have one Vehicle. Role ENUM('Passenger', 'Driver')

 Driver-Ride (One-to-Many) );

One Driver can be associated with multiple


Rides, but each Ride is associated with one INSERT INTO Users (UserID,Username,
Driver. Password, FirstName, LastName, Email,
 Passenger-Ride (One-to-Many) Phone, Role)

One Passenger can be associated with multiple VALUES


Rides, but each Ride is associated with one (1,'user1', 'ABC1', 'Suraj', 'Singh',
Passenger. 'Suraj@gmail.com', '1234567890',
 Ride-RideType (Many-to-One) 'Passenger'),

Many Rides can have the same RideType, but (2,'user2', 'ABC2', 'Raja', 'Kumar',
each Ride is associated with one RideType. 'Raja@gmail.com', '9876543210', 'Driver'),

 User-Rating (One-to-Many) (3,'user3', 'ABC3', 'Ankit', 'Kumar',


'Ankit@gmail.com', '5551234567',
One User can give multiple Ratings, and one 'Passenger'),
User can receive multiple Ratings.
(4,'user4', 'ABC4', 'Rahul', 'Kumar',
'Rahul@gmail.com', '5559876543',
d) Assumptions and Justifications: 'Driver'),
I assume that each ride can have only one (5,'user5', 'ABC5', 'Eva', 'Kumar',
passenger and one driver. 'Eva@gmail.com', '7771112222',
A user can be both a passenger and a 'Passenger'),
driver, which is why I used a (6,'user6', 'ABC6', 'David', 'Kumar',
generalization for the User entity. 'David@gmail.com', '3334445555',
RideType entity is used to categorize 'Driver'),
different types of rides (e.g., economy,
premium) with varying fare structures.
(7,'user7', 'ABC7', 'Neeraj', 'Kumar', ('P6', 6, 'Chapra'),
'Neeraj@gmail.com', '8889990000',
('P7', 7, 'Sonpur'),
'Passenger'),
('P8', 8, 'Hajipur'),
(8,'user8', 'ABC8', 'Dhiraj', 'Kumar',
'Dhiraj@gmail.com', '2223334444', ('P9', 9, 'Guntur'),
'Driver'),
('P10', 10, 'Naya Gaon');
(9,'user9', 'ABC9', 'Om', 'Kumar',
'Om@gmail.com', '1112223333',
'Passenger'), select *from Passenger
(10,'user10', 'ABC10', 'Ashif','Kumar', OUTPUT :-
'Ashif@gmail.com', '6667778888',
'Driver');

OUTPUT :-

 Passenger :-  Driver :-
CREATE TABLE Passenger ( CREATE TABLE Driver (
PassengerID INT PRIMARY KEY, DriverID INT PRIMARY KEY,
UserID INT UNIQUE, UserID INT UNIQUE,
Address VARCHAR(200), VehicleInfo VARCHAR(100),
FOREIGN KEY (UserID) REFERENCES AvailabilityStatus BOOLEAN,
User(UserID)
FOREIGN KEY (UserID) REFERENCES
); User(UserID)
);
INSERT INTO Passenger (PassengerID,
UserID, Address)
INSERT INTO Driver (DriverID,
VALUES UserID, VehicleInfo, AvailabilityStatus)
('P1', 1, 'Parmanadpur'), VALUES
('P2', 2, 'Murthan'), ('D1', 1, 'Maruti', TRUE),
('P3', 3, 'Harpunand'), ('D2', 2, 'Honda ', TRUE),
('P4', 4, 'Vadlamudi'), ('D3', 3, 'Ford ', FALSE),
('P5', 5, 'Patna'), ('D4', 4, 'Maruti AC', TRUE),
('D5', 5, 'Altima', FALSE), (14, 'Senior Citizen', 9.00),
('D6', 6, 'Hyundai', TRUE), (15, 'Student', 8.50);
('D7', 7, 'Kia Optima', FALSE),
('D8', 8, 'Volkswagen Passat', TRUE), select *from RideType
('D9', 9, 'BMW', TRUE), OUTPUT :-
('D10', 10, 'RR', FALSE);

select *from Driver;

OUTPUT :-

 Ride :-
CREATE TABLE Ride (
 RideType
RideID INT PRIMARY KEY,
CREATE TABLE RideType (
PassengerID INT,
RideTypeID INT PRIMARY KEY,
DriverID INT,
TypeName VARCHAR(50) NOT NULL,
PickupLocation VARCHAR(200) NOT
BaseFare DECIMAL(10, 2) NOT NULL
NULL,
);
Destination VARCHAR(200) NOT
NULL,
INSERT INTO RideType (RideTypeID, RideTypeID INT,
TypeName, BaseFare)
EstimatedFare DECIMAL(10, 2),
VALUES
Status VARCHAR(20) NOT NULL,
(6, 'Express', 15),
FOREIGN KEY (PassengerID)
(7, 'Standard', 12.00), REFERENCES Passenger(PassengerID),
(8, 'Deluxe', 35.00), FOREIGN KEY (DriverID)
REFERENCES Driver(DriverID),
(9, 'Airport Shuttle', 18.00),
FOREIGN KEY (RideTypeID)
(10, 'Business', 40.00), REFERENCES RideType(RideTypeID)
(11, 'Family', 22.00), );
(12, 'Electric', 27.00),
(13, 'Sports Car', 50.00),
INSERT INTO Ride (RideID, Comment TEXT,
PassengerID, DriverID, PickupLocation,
FOREIGN KEY (RideID) REFERENCES
Destination, RideTypeID, EstimatedFare,
Ride(RideID),
Status)
FOREIGN KEY (RatedUserID)
VALUES
REFERENCES User(UserID)
(1, 'P1', 'D1', 'Parmanandpur', 'Digha',
);
'RI1', 25, 'Completed'),
INSERT INTO Rating (RatingID,
(2, 'P2', 'D2', 'Murthan', 'Apshaid','RI2', 30,
RideID, RatedUserID, Stars, Comment)
'Completed'),
VALUES
(3, 'P3', 'D3','Sonpur', 'Muzafferpur', 'RI3',
20, 'In Progress'), ('RT1', 1, 1, 5, 'Great ride!'),
(4, 'P4', 'D4','Vadlamudi', 'Sitamadhi', ('RT2', 2, 2, 4, 'Good experience.'),
'RI4', 35, 'Completed'),
('RT3', 3, 3, 3, 'Average ride.'),
(5, 'P5', 'D5', 'Naya Gaon', 'Madhubani',
'RI5', 15, 'Completed'), ('RT4', 4, 4, 5, 'Excellent driver.'),

(6, 'P6', 'D6', 'Patna', 'Purnia', 'RI6', 28, ('RT5', 5, 5, 2, 'Not satisfied.'),
'Completed'), ('RT6', 6, 6, 4, 'Friendly driver.'),
(7, 'P7', 'D7', 'Chapra', 'Parmanandpur', ('RT7', 7, 7, 5, 'Smooth ride.'),
'RI7', 22, 'In Progress'),
('RT8', 8, 8, 1, 'Terrible experience.'),
(8, 'P8', 'D8', 'Gandhi Chawk', 'Hajipur',
'RI8', 32, 'Completed'), ('RT9', 9, 9, 3, 'Okay ride.'),

(9, 'P9', 'D9', 'Sitabganj', 'Nijam chawk', ('RT10', 10, 10, 4, 'Good Ride');
'RI9', 18, 'Completed'),
(10, 'P10', 'D10', 'Purnia', 'Hajipur', 'RI10', SELECT *FROM Rating;
37, 'Completed');
select *FROM Ride;

OUTPUT :-

OUTPUT :-

 Rating :-
CREATE TABLE Rating (
RatingID INT PRIMARY KEY,
RideID INT UNIQUE,
RatedUserID INT,
Stars INT,
5. SCHEMA DIAGRAM :-
7. REFERENCES
1. JavaTpoint
https://www.javatpoint.com/dbms-sql -
command
2. LucidChart
https://www.lucidchart.com/pages/er-
diagrams::text=A

6. CONCLUSION
This case study outlines the design and
development of a real-time ride-sharing
system, aiming to revolutionize the way
passengers and drivers connect for efficient
transportation. By seamlessly connecting
passengers with available drivers, the system
streamlines the process of requesting and
providing rides. Key objectives include user
registration, ride request handling, real-time
driver availability updates, fare estimation,
real-time tracking, and user rating feedback.
The system is designed to accommodate
various user roles, including passengers and
drivers, with functionalities tailored to their
specific needs. Passengers can create accounts,
request rides by specifying pickup and
destination details, and choose preferred ride
types. On the other hand, drivers can register,
manage their vehicle information, update their
availability status, and offer rides to
passengers. The system’s real-time tracking
feature ensurestransparency and safety by
allowing passengers to monitor their ride’s
progress. The estimated fare calculation takes
into account factors such as distance, ride
type, and additional charges, providing
passengers with an accurate expectation of
costs.

You might also like