{"id":27261465,"url":"https://github.com/devlm7/3_sql_database_getrail","last_synced_at":"2025-04-11T05:33:24.624Z","repository":{"id":287222416,"uuid":"964021251","full_name":"DevLM7/3_SQL_Database_GetRail","owner":"DevLM7","description":"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.","archived":false,"fork":false,"pushed_at":"2025-04-10T15:27:55.000Z","size":7162,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T16:46:12.729Z","etag":null,"topics":["database-management","python","sql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DevLM7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-10T15:10:02.000Z","updated_at":"2025-04-10T15:29:22.000Z","dependencies_parsed_at":"2025-04-11T05:33:10.838Z","dependency_job_id":null,"html_url":"https://github.com/DevLM7/3_SQL_Database_GetRail","commit_stats":null,"previous_names":["devlm7/sql_database_getrail"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevLM7%2F3_SQL_Database_GetRail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevLM7%2F3_SQL_Database_GetRail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevLM7%2F3_SQL_Database_GetRail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevLM7%2F3_SQL_Database_GetRail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevLM7","download_url":"https://codeload.github.com/DevLM7/3_SQL_Database_GetRail/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248347786,"owners_count":21088743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database-management","python","sql"],"created_at":"2025-04-11T05:32:29.340Z","updated_at":"2025-04-11T05:33:24.599Z","avatar_url":"https://github.com/DevLM7.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# 🚆 GetRail - Railway Reservation System\n\n## 📘 Description\n**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.\n\n---\n\n## 📁 Tables Overview\n\n- **Passenger**: Stores personal details of railway users.  \n- **Payment**: Stores payment mode for each passenger.  \n- **Ticket**: Stores ticket details linked to passengers and trains.  \n- **TrainDetails**: Contains information about different trains.  \n- **TechnicalSupervisor**: Stores supervisors managing the trains.  \n- **TrainManagement**: Mapping table linking trains with supervisors.\n\n---\n\n## 📥 Data Insertion\n- Added 15 passengers, 8 supervisors, and 5 trains.\n- Assigned supervisors to trains via `TrainManagement`.\n- Issued tickets to passengers.\n- Recorded payment modes.\n\n---\n\n## ✏️ Data Modification Operations\n- `UPDATE` to correct phone numbers, ages, and emails.\n- `DELETE` to remove incorrect records (payment and supervisor mappings).\n- Additional `INSERT` queries to maintain consistency.\n\n---\n\n## 🔢 Number Functions\n- Calculated average, maximum, and minimum age of passengers.\n- Counted total tickets.\n- Example queries using `ROUND()` and `SUM()`.\n\n---\n\n## 🔤 Character Functions\n- Converted names to uppercase/lowercase.\n- Extracted prefixes using `LEFT()`.\n- Calculated name length and concatenated data.\n\n---\n\n## 🔍 SELECT Queries \u0026 Conditions\n- Tickets by reservation status.\n- Name pattern searches.\n- Trains going to specific destinations.\n- Passengers in age ranges.\n\n---\n\n## 🔗 SQL Joins\n- `INNER JOIN`, `LEFT JOIN`, `RIGHT JOIN`, `FULL OUTER JOIN`, `CROSS JOIN` on passengers, tickets, and trains.\n\n---\n\n## ⚙️ Trigger\n- `after_ticket_insert`: Adds a pending payment when a ticket is booked.\n\n---\n\n## 👤 User Management\n- Created and granted privileges to a new user.\n- Demonstrated `GRANT` and `REVOKE` operations.\n\n---\n\n## 🧠 Functional Dependencies \u0026 3NF\n- Described FDs and derived candidate keys using attribute closure.\n- Example of relation decomposition into 3NF.\n\n---\n\n## 🐍 Python Integration\n- Connected MySQL database with Python using `mysql.connector`.\n- Inserted new records and fetched data with exception handling.\n- Example snippet:\n\n```python\ntry:\n    cursor.execute(\"SELECT * FROM students\")\n    results = cursor.fetchall()\n    for row in results:\n        print(row)\nexcept mysql.connector.Error as err:\n    print(f\"Error: {err}\")\nfinally:\n    cursor.close()\n    db_connection.close()\n```\n\n---\n\n## 📊 Bonus Queries\n\n- String pattern matching:\n\n```sql\nSELECT * FROM Passenger WHERE name LIKE 'Tend%ar';\n```\n\n- Sorting query:\n\n```sql\nSELECT * FROM Passenger ORDER BY age ASC;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevlm7%2F3_sql_database_getrail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevlm7%2F3_sql_database_getrail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevlm7%2F3_sql_database_getrail/lists"}