database assignment
database assignment
Group Members
NAME ID
1.Abenezer Amado……………………318374/16
3.Temesgen Abebe…………….328669/16
4.Yeabsra Tesfaye………………….044683/16
5.Biruk Shamena……………………..2678/16
132328/16
132328/16
6.Goner tut.........................................4934/16
1|Page
Table of Content
1. relationship(foreign key )
2. Primary Key and Foreign Key
3. Entities and attributes (Logical Design)
4. Physical design
5. Sql query and graphs
6. Documentation (References)
2|Page
1.relationship(foreign key )
• Entity Identification:
• Bus: Represents a bus used for transportation.
• Route: Represents a path from an origin to a destination.
• Trip: Represents a scheduled journey of a bus along a route.
• Customer: Represents a person who books a trip.
• Booking: Represents a reservation of a seat on a particular trip.
• Payment: Represents the financial transaction for a booking.
• Attribute Definition:
• Bus:
* BusID (unique identifier for each bus)
* BusName
* Capacity (number of seats)
* Type (e.g., luxury, standard, mini)
• Route:
* RouteID (unique identifier for each route)
* Origin (starting location)
* Destination (ending location)
* Distance
• Trip:
* TripID (unique identifier for each trip)
* BusID (foreign key referencing the Bus entity)
Customer:
* CustomerID (unique identifier for each customer)
* Name
* PhoneNumber
* Email
* Booking:
* BookingID (unique identifier for each booking)
* CustomerID (foreign key referencing the Customer entity)
* TripID (foreign key referencing the Trip entity)
* BookingDate (date when the booking is made)
* Status (e.g., pending, confirmed, cancelled)
* Payment:
* PaymentID (unique identifier for each payment)
* BookingID (foreign key referencing the Booking entity)
* Amount (payment amount)
3|Page
* PaymentMethod (e.g., credit card, mobile money)
* PaymentDate (date of payment)
• Relationship Definition:
* One Bus can have many Trip records (one-to-many)
* One Route can have many Trip records (one-to-many)
* One Customer can have many Booking records (one-to-many)
* One Trip can have many Booking records (one-to-many)
* One Booking record can have one Payment record (one-to-one).
• Conceptual ERD
A visual representation of this diagram has been shown before.
• Characteristics:
• Uniqueness: Every value in the primary key column must be unique. No two
rows can have the same primary key value.
• Not NULL: The primary key column cannot contain NULL values. Every
row must have a primary key value.
• Purpose:
4|Page
• Example: In a Customers table, customer_id is often used as the primary key.
Each customer has a unique customer_id.
* Foreign Key:
• Definition: A foreign key is a column (or a set of columns) in one table that
refers to the primary key of another table. It establishes a link or relationship
between the two tables.
• Characteristics:
• References Primary Key: The foreign key column must reference the primary
key column of another table.
• Referential Integrity: The values in the foreign key column must either match
a value in the referenced primary key column or be NULL (depending on how the
foreign key constraint is defined). This ensures that relationships between tables
remain consistent.
• Purpose:
5|Page
• Table Definition:
* Trip: Stores trip schedule and fare information with foreign keys linking to
Bus and Route tables
• Column Definitions:
* Bus:
* BusName VARCHAR(255)
* Capacity INT
* Type VARCHAR(50)
* Route:
* Origin VARCHAR(255)
* Destination VARCHAR(255)
* Distance DECIMAL(10,2)
* Trip:
6|Page
* RouteID INT, FOREIGN KEY (RouteID) REFERENCES Route(RouteID)
* Schedule DATETIME
* Fare DECIMAL(10,2)
* Customer:
* Name VARCHAR(255)
* PhoneNumber VARCHAR(20)
* Email VARCHAR(255)
* Booking:
* BookingDate DATE
* Status VARCHAR(50)
* Payment:
* Amount DECIMAL(10, 2)
* PaymentMethod VARCHAR(50)
* PaymentDate DATE
7|Page
• Logical ERD
The textual diagram for the logical ERD was presented before.
• Normalization
Normalization ensures that the data model adheres to the following rules:
4. Physical Design
• Database System Selection:
• Storage Structures:
8|Page
Data will be stored using default MySQL storage engines. Indexing will be added
on the primary keys and the foreign keys.
• Data Types:
Data types for columns have already been defined using specific MySQL syntax.
• Hardware Requirements:
• Security:
Implement password protection for the database, and create different user roles
for different staff levels.
Implement daily full database backups and transaction logs for rollbacks.
Backups should be stored in a different server for safety.
• Implementation Details:
The following user transactions identified in the mission objectives have been
validated against the relations:
9|Page
Booking details are stored in the Booking table, linked to the
o
Passenger and Schedule tables.
2. View and Update Bus Schedules
o Bus operators can update the Schedule table, which links buses
(BusID) to routes (RouteID).
3. Manage Payments
o Payments are tracked in the Payment table, linked to the Booking
table.
o Attributes like PaymentMethod and PaymentStatus ensure
flexibility and transparency.
4. Retrieve Booking History
o Passengers can view their booking history by querying the Booking
table using their PassengerID.
5. Generate Reports
o Bus operators and administrators can generate reports using joins
between Bus, Route, Schedule, and Booking tables.
10 | P a g e
*ER Diagram
11 | P a g e
page 11
6.Documentation (References)
• Citations:
* Database Normalization
* MySQL Documentation
Customer Table
Bus Table
Route Table
12 | P a g e
Trip Table
Booking Table
Payment Table
This logical design is both normalized and aligned with the system's mission objectives to ensure
data integrity, efficiency, and user satisfaction.
13 | P a g e