Airline booking: away/return directions, a double-entry ledger and change history
Airline case study, part 3: splitting a booking into directions and money lines, storing money properly, tickets and passengers, a double-entry ledger with a balance constraint in PostgreSQL, optimistic locking with a version column and a booking_history table, and other ways to keep history.