Round 2
Questions: Design LLD of IRCTC train ticket booking system
Functional Requirements:
- Users should be able to search trains by train number and via source, destination, and date.
- Users should be able to see the number of available seats, given the train, source, destination, and date.
- Users should be able to book tickets (The system should be able to handle concurrent booking requests in a fair manner).
- Seat reusability of booked seats is allowed (User A books a seat S1 from station1 to station2, then User B should be able to book the same seat S1 from station3 onwards).
- Users should be able to cancel a booked ticket.
Assumptions:
- A train will run from source to destination once a day. In the case of the reverse journey, the ID of the train will change and it will be treated as a new train itself.
- To keep things simple, we will not consider the berth and coach preference in this article.
- There will be only one coach in a train.
- We will also only book tickets that are confirmed; waitlisting is not supported.
Discussed the solution stepwise:
- Flow
- Actors and Actions
- Entities and Relationship
- DB Design
The interview was more interested in DB design. Explained the DB design using SQL. Started with these entities:
- User
- Train
- Seat
- Booking
For seat reusability, introduced a new entity segment. The interviewer was focused on design more than actual implementation.
Candidate's Approach
The candidate discussed the design stepwise, focusing on the flow of the system, the actors involved, and the relationships between entities. The database design was emphasized, with a clear explanation of the entities involved and their relationships. The candidate introduced a new entity for seat reusability to address the functional requirements effectively.
Interviewer's Feedback
The interviewer was primarily interested in the database design and appreciated the candidate's structured approach to discussing the solution. Feedback on the design aspects was positive, indicating a good understanding of the requirements.