       (sort-by (comp :price deref))
       (first))))
 
-(defn reserve [reservation relation n-seats]
+(defn reserve-relation [reservation relation n-seats]
   "Reserve `n-seats` on `relation`, for `reservation`.
 
   Decreases the number of seats in `relation`, and updates the total in

  (dosync
    (alter relation update :seats - n-seats)
    (alter reservation update :total + (:price @relation))))

(defn process-reservation
  [reservation

  (dosync
    (let [found-car    (look-for-seats (random-subset n-queries cars) 1)
          found-flight (look-for-seats (random-subset n-queries flights) 1)
          found-room   (look-for-seats (random-subset n-queries rooms) 1)
          pnr          (generate-pnr reservation)]
      (when found-car    (reserve-relation reservation found-car 1))
      (when found-flight (reserve-relation reservation found-flight 1))
      (when found-room   (reserve-relation reservation found-room 1))
      (alter reservation assoc
        :status true
        :pnr    pnr))))
; TODO: add some logging

; BEHAVIORS
