Track & Time is a comprehensive web application built with PHP and MySQL. It serves as both a precise segment-level train timing calculator and a foundational Railway Reservation Database System.
While traditional railway applications focus only on the entire journey from source to destination, this project uses an optimized Relational Database approach to calculate exact departure, arrival, and travel duration for specific segments along a train's route.
Core Features & Logic
Smart Directional Routing: The core of the application relies on an advanced SQL join logic (r1.stoporder < r2.stoporder). This ensures the system accurately determines if a train is physically traveling forward between the user's selected stations, filtering out invalid reverse routes.
Segment-Level Timings: Instead of showing the train's total journey time, the system dynamically calculates the duration for the user's specific segment using MySQL's TIMEDIFF() functions.
Comprehensive Data Tracking: Built on top of a highly normalized database that supports not just route finding, but also full ticket booking, user management, and passenger tracking.
Dynamic UI Interaction: Features a JavaScript-powered "Swap" (⇄) button that instantly reverses the source and destination inputs without requiring a page reload.
Detailed Route View: A dedicated details page that fetches the complete stop-by-stop schedule, highlighting precise arrival/departure timings and dynamic ticket pricing.
Tech Stack
Frontend: HTML5, CSS3, JavaScript (DOM Manipulation)
Backend: PHP 8.x
Database: MySQL (Relational Database with Foreign Key constraints)
Architecture: Monolithic Web App (XAMPP/WAMP environment)
Database Schema & Architecture
The system features a robust, enterprise-grade relational database structure. Here is a simplified view of the core tables:
- Stations Table
Master directory mapping station codes to their full names.
| Column Name | Data Type | Description |
|---|---|---|
| Code (PK) | VARCHAR(10) | Unique Station Code (e.g., MAS) |
| StationName | VARCHAR(100) | Full Name (e.g., Chennai Central) |
- Trains Table
Holds the primary train information.
| Column Name | Data Type | Description |
|---|---|---|
| TrainID (PK) | INT | Unique Identifier |
| TrainNumber | VARCHAR(20) | IRCTC Train Number |
| TrainName | VARCHAR(100) | Name of the Train |
| SourceName | VARCHAR(100) | Origin Station |
| DestName | VARCHAR(100) | Final Destination |
- TrainRoutes Table (The Core Engine)
Maps the stops for each train. The stoporder column is critical for the directional routing logic.
| Column Name | Data Type | Description |
|---|---|---|
| RouteID (PK) | INT | Unique Route Identifier |
| TrainID (FK) | INT | Links to Trains table |
| StationCode (FK) | VARCHAR(10) | Links to Stations table |
| StopOrder | INT | Defines the sequence of stops |
| ArrivalTime | TIME | Segment Arrival Time |
| DepartureTime | TIME | Segment Departure Time |
| TicketPrice | DECIMAL | Dynamic fare for the segment |
(Note: The database also includes Users, Bookings, and Passengers tables to handle full reservation workflows.)