Design BookMyShow

  • 6

    Describe how would you design an online ticketing system that sells movie tickets like BookMyShow.

    Where: I was asked this problem for an interview for Oracle.

    Solution: I started with defining goals and requirement of the system. Few functional and non functional requirement are as follows -

    Functional Requirements:

    1. The system should be able to list down cities where its cinemas are located.
    2. Upon selecting the city, the system should display the movies released in that particular city to that user.
    3. Once the user makes his choice of the movie, the system should display the cinemas running that movie and its available shows.
    4. The user should be able to select the show from a cinema and book their tickets.
    5. The system should be able to show the user the seating arrangement of the cinema hall.
    6. The user should be able to select multiple seats according to their choice.
    7. The user should be able to distinguish between available seats from the booked ones.
    8. Users should be able to put a hold on the seats for 5/10 minutes before they make a payment to finalize the booking.
    9. The system should serve the tickets First In First Out manner

    Non-Functional Requirements:

    1. The system would need to be highly concurrent as there will be multiple booking requests for the same seat at any particular point in time. The design should be such that system handles such ambiguity fairly.
    2. Secure and ACID compliant.

    Database Model:

    1. City
    2. Movie
    3. Cinema
    4. Cinema Hall
    5. Show
    6. Seat
    7. Booking
    8. User
    9. Payment

    Relationships between them:

    1. A City can have multiple Cinemas.
    2. A Cinema can have multiple halls.
    3. A Movie can will have many Shows.
    4. A Show will have multiple Bookings.
    5. A User can have multiple bookings.

    How to handle concurrency such that no two users are able to book same seat?
    Utilize transaction isolation levels.
    SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; for the seat and booking update. As Serializable level guarantees safety from Dirty, Nonrepeatable and Phantoms reads.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.