- Are we going to write code or a class diagram is enough?
- Code is required.
- Are we going to persist the data?
- Yes
- How will user use the system?
- Using GET and POST request.
- Admin
- Adds new city
- Adds new theatre
- Theatre Owner
- Adds audis to the theatre.
- Adds shows to the theatre.
- Customer
- Select Cities.
- Search a Movie
- List of theatres
- Select theatres.
- List of shows.
- Select a show.
- Select seats.
- Make Payment
- Get Ticket
- BMS will have multiple cities.
- Cities will have multiple theatre.
- Theatre will have multiple audis.
- Audis will have multiple seats.
- Each Seat will have a type.
- Audis will have available features.
- Shows will have required features.
- Shows has start and end time.
- Multiple seats can be booked with a single ticket.
- Limit number of seat allowed to be booked with 1 ticket.
- Status [ Available, Locked, Booked , Not available ] is a seat in a show.
- Price is related to seat type in the show.
| ENUMS | CLASSES |
|---|---|
| Seat Type | Cities |
| Role | Theatre |
| Features | Audis |
| Seat Status | Shows |
| Theatre Status | Tickets |
| Payment Mode | Payment |
| Payment Status | User |
| Seat | |
| Bill | |
| SeatInShow | |
| SeatTypeInShow |
- SeatType: Silver, Gold, Platinum
- Role: Admin, owner, user
- Features: 2D, 3D, DOLBY, 4D
- SeatStatus: available, under_maintainance, locked, booked
- TheatreStatus: open, closed
- Payment Mode: card, netbanking
- Payment Status: failed, successful, in-process
| City |
|---|
| id |
| name |
| list (theatres) |
| Theatre |
|---|
| id |
| name |
| address |
| list (audis) |
| maxBookingSeatAllowed |
| Audis |
|---|
| id |
| name |
| list (Seats) |
| list (features) |
| rows |
| columns |
| seat |
|---|
| id |
| number |
| seatType |
| Row |
| Coloumn |
| User |
|---|
| id |
| list (role) |
| username |
| password |
| Show |
|---|
| id |
| start time |
| end time |
| audi |
| name |
| list (features) |
| seatInAShow |
|---|
| id |
| Seat |
| show |
| seatStatus |
| seatTypeInShow |
|---|
| id |
| seatType |
| show |
| price |
| Ticket |
|---|
| id |
| user |
| booking time |
| list (SeatInShow) |
| list (payment) |
| user |
| Payment |
|---|
| id |
| payementStatus |
| paymentProvider |
| amount |
| transaction id |
| ticket |
- Classes & enums become table.
- Primitive Attributes should be the columns - Primitive data types. - string - date/time
- Relationship : (1:1): any side FK, (1:M): on m side FK , (M:M): mapping table
- All enums as tables with two coloumns -> id and value
- City : id, name
- Theatre: id, name, address, maxSeatBookingAllowed, cityID
- Audi: id, name, rows, coloumns, theatreId
- User: id, name, password, username
- Seat : id, number, row, coloumn, audiId, seatTypeId
- Show: id, name, start_time, end_time, audiId
- Ticket: id, booking_time, user_id
- Payment: id, amount, transaction_id, ticket id
- SeatInShow: id, seatIId, showId, seatStatusId
- SeatTypeInShow: id, price, seattypeID, showId
- AudiFeatures: id, audiId, featureId
- UserRole: id, userId, roleId
- ShowFeature: id, showId, featureId
- Getter -> Add getter methods
- Setter -> Add the setter Methods
- Entity -> For creating table
- MappedSuperClass -> to make properties part of another table
- Id -> To treat it as primary key
- GeneratedValue -> For auto increment
- OneToMany (mappedBy="")
- ManyToOne
- OneToOne
- ManyToMany
-
Enumerated -> For enums
-
ElementCollection -> For list of enums
-
Rather than creating dependency object and then injecting in the constructor we could use following annotations of springboot:
- Controller
- Autowired
- Service
- Repository
If user1 selected A1 and A2 seat at 9:05 and user2 selected A2 and A3 seats at 9:05. User 1 clicked on book ticket at 9:06 and user2 at 9:07.
Locked the seat A1 and A2 at 9:06 and dummy ticket is generated.
- Get showSeats of selected IDs
- Check if they are avaialabe.
- If not available, send back with an exception
- else Lock them
- Prepare dummy ticket
- Return Ticket
Selected Seat -> Locked -> Login -> sent to Payment Gateway -> Pay -> Success -> Redirected to BMS-> Success -> Ticket Status Booked
- What will be added in the the dummy ticket and when? Select (ShowSeatId) -> Login (UserId) -> Pay (PaymentId)
| Payment | Redirection | Status |
|---|---|---|
| Success | Success | Booked |
| Success | Failed | Locked and Refund should be initiated |
| Failed | Success | Not Booked and locked |
| Failed | Failed | Locked |
- Locked should be considered available after 6 minutes.
- Locked : Now - lockedAt < 6 minutes -> locked else consider it available.
If redirection succeed, then BMS knows what to do and what actually happened.
- Reconciliation
- BookMyShow and Payment Gateway maintains files at their end for all the entries.
- Files are compared get the difference (Breaks).
- Refund needs to be initiated.
- External Breaks: External party have additional entries.
SET TRANSACTION ISOLATION LEVEL SERIALISABLE
-
Read with lock (Select for update)
-
Check in App
-
Update
-
ORM
-
Pessimistic Read/Write
-
Different types of locks in Transactional
