https://github.com/devlm7/3_sql_database_getrail
GetRail is a fully-featured railway reservation database project designed using MySQL. It manages passengers, tickets, trains, payments, and technical supervisors. This system includes advanced SQL features like views, joins, triggers, user privileges, string/number functions, and Python database interaction.
https://github.com/devlm7/3_sql_database_getrail
database-management python sql
Last synced: about 1 year ago
JSON representation
GetRail is a fully-featured railway reservation database project designed using MySQL. It manages passengers, tickets, trains, payments, and technical supervisors. This system includes advanced SQL features like views, joins, triggers, user privileges, string/number functions, and Python database interaction.
- Host: GitHub
- URL: https://github.com/devlm7/3_sql_database_getrail
- Owner: DevLM7
- Created: 2025-04-10T15:10:02.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-10T15:27:55.000Z (about 1 year ago)
- Last Synced: 2025-04-10T16:46:12.729Z (about 1 year ago)
- Topics: database-management, python, sql
- Language: Python
- Homepage:
- Size: 6.83 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🚆 GetRail - Railway Reservation System
## 📘 Description
**GetRail** is a robust railway reservation database management system built using **MySQL** and integrated with **Python**. It includes various entities like passengers, trains, tickets, payments, and technical supervisors. The system supports advanced operations including data manipulation, SQL functions, triggers, joins, and Python-based interactions.
---
## 📁 Tables Overview
- **Passenger**: Stores personal details of railway users.
- **Payment**: Stores payment mode for each passenger.
- **Ticket**: Stores ticket details linked to passengers and trains.
- **TrainDetails**: Contains information about different trains.
- **TechnicalSupervisor**: Stores supervisors managing the trains.
- **TrainManagement**: Mapping table linking trains with supervisors.
---
## 📥 Data Insertion
- Added 15 passengers, 8 supervisors, and 5 trains.
- Assigned supervisors to trains via `TrainManagement`.
- Issued tickets to passengers.
- Recorded payment modes.
---
## ✏️ Data Modification Operations
- `UPDATE` to correct phone numbers, ages, and emails.
- `DELETE` to remove incorrect records (payment and supervisor mappings).
- Additional `INSERT` queries to maintain consistency.
---
## 🔢 Number Functions
- Calculated average, maximum, and minimum age of passengers.
- Counted total tickets.
- Example queries using `ROUND()` and `SUM()`.
---
## 🔤 Character Functions
- Converted names to uppercase/lowercase.
- Extracted prefixes using `LEFT()`.
- Calculated name length and concatenated data.
---
## 🔍 SELECT Queries & Conditions
- Tickets by reservation status.
- Name pattern searches.
- Trains going to specific destinations.
- Passengers in age ranges.
---
## 🔗 SQL Joins
- `INNER JOIN`, `LEFT JOIN`, `RIGHT JOIN`, `FULL OUTER JOIN`, `CROSS JOIN` on passengers, tickets, and trains.
---
## ⚙️ Trigger
- `after_ticket_insert`: Adds a pending payment when a ticket is booked.
---
## 👤 User Management
- Created and granted privileges to a new user.
- Demonstrated `GRANT` and `REVOKE` operations.
---
## 🧠 Functional Dependencies & 3NF
- Described FDs and derived candidate keys using attribute closure.
- Example of relation decomposition into 3NF.
---
## 🐍 Python Integration
- Connected MySQL database with Python using `mysql.connector`.
- Inserted new records and fetched data with exception handling.
- Example snippet:
```python
try:
cursor.execute("SELECT * FROM students")
results = cursor.fetchall()
for row in results:
print(row)
except mysql.connector.Error as err:
print(f"Error: {err}")
finally:
cursor.close()
db_connection.close()
```
---
## 📊 Bonus Queries
- String pattern matching:
```sql
SELECT * FROM Passenger WHERE name LIKE 'Tend%ar';
```
- Sorting query:
```sql
SELECT * FROM Passenger ORDER BY age ASC;
```