Data and states
What are the conditions R-17 needs?
Vehicle, reservation and rental have their own identities and life cycles. We plot their relationships, allowed state changes and the boundary of a common database transaction.
Starting point From step 4: API contract and stable keys distinguish accepted orders from confirmed results; vehicle A remains reserved for 9-12 o’clock.
Assumptions for the example case
Example design: an operator, specifically assigned vehicles, planned periods and a region. Figures are illustrative design assumptions, not company data.
The Central Relationships
1 : n = one person, several reservations. Each payment order belongs to the reservation; later billing orders additionally relate to the rental.
Life cycle of a reservation
Reservation and rental separately lead
Reservation R-17
Authorisation to accept confirmationconfirmed
Release holdexpired
Cancellation of bookingcancelled
Rental M-17 for vehicle A
Time expiration, cancellation and external feedback are conducted as visible transitions. A timestamp alone does not set a reservation status.
Hold and follow-up order atomically stored
Secure reservation and follow-up order together
Commit · both changes
All local checks and writes succeed.
Rollback · Discard local changes
The two results show the local transaction limit. External effects cannot simply be rolled back in the event of a later error, but can only be compared or compensated.
Access patterns determine the data storage
Further reading
| Access | Required property |
|---|---|
| Find free vehicle for location and period | Indices on search characteristics and a searchable occupancy period. |
| Write Hold for Vehicle and Period | A transaction with a binding check that prevents overlapping effective occupancy even in the case of simultaneous requests. |
| Read your own reservation and rental | Direct access via ID plus verification of the authorized person. |
| Assigning a provider response to an order | Unique order identity and provider reference; separate payment and access states. |
Find free vehicle for location and period
- Required property
- Indices on search characteristics and a searchable occupancy period.
Write Hold for Vehicle and Period
- Required property
- A transaction with a binding check that prevents overlapping effective occupancy even in the case of simultaneous requests.
Read your own reservation and rental
- Required property
- Direct access via ID plus verification of the authorized person.
Assigning a provider response to an order
- Required property
- Unique order identity and provider reference; separate payment and access states.
The table connects each task to a property of data storage. The vehicle search needs suitable data sets by location and time period; indices speed up this selection. A reservation, on the other hand, must take account of simultaneously arriving booking attempts and securely store associated changes. Therefore, we select data structure and protection rules for the respective access.
Select database types consciously
Further reading
Share bookings and occupancy consistently
Tables represent vehicles, reservations and orders with clear relationships. Transactions aggregate associated changes into one unit. Thus, the application can reliably change booking data together. The specific SQL database product is selected during the technical implementation.
- Trade-off
- Schema, indices and transaction limits need care. The protection against overlapping periods of time must be implemented appropriately for the selected product and tested under simultaneous access.
- Reassess
- Re-assess in case of measured overload or new query patterns.
Maintain order data initially in relational data store
Tables and direct accesses via unique IDs are sufficient for the described jobs. A dedicated document or key-value store would add storage to reconcile and operate.
- Trade-off
- For later, very special accesses, the relational model may be less tailored.
- Reassess
- High telemetry load or an independent document stock with other accesses justify a new check.
Query relationships across tables and links
The booking core follows fixed relationships: a person has reservations, a reservation occupies a vehicle. These accesses can be mapped directly via the linked tables.
- Trade-off
- Multi-stage, variable relationship paths would thus be more complex to evaluate.
- Reassess
- A separate case with frequent path queries, for example via a complex authorization network, could justify a graph projection.
Terms in this step
- Transaction
- A unit of related database changes. Here, reservation and internal order are confirmed jointly by a commit.
- Rollback
- The rejection of the changes of a still open transaction. Here, it prevents that only a part of the booking data remains stored after an error.
- Hold
- A temporary occupancy, while further requirements are examined.
Try it yourself
When storing R-17, the writing of the subsequent order fails. What can be visible after the rollback? Can a payment response still trigger confirmed after the hold period has expired?
A hint for your attempt
Note two limits: shared local data and a permitted change of state before the deadline.
Compare with a possible solution
- Rollback
- Neither the new Hold R-17 nor its follow-up order will be committed. As a result, no hold is left without a planned payment check.
- Delayed response
- No. The confirmation checks the state and time limit atomically. The overdue hold transitions to expired; an existing authorization will be cancelled or handed over for clarification.
Apply to your project
Transfer states, transition conditions, and transaction boundary to your own core item and record an earlier design step to revisit that could test an earlier assumption.