Parks reservations must not allow overlapping bookings for the same facility_id and time range. Which programmability approach enforces that rule on insert?
Select an answer to reveal the explanation.
Short Explanation
You can think of the trigger as the schedule referee: when a new booking overlaps an existing booking for the same facility, it rejects the insert. A sequence assigns numbers, but it cannot detect calendar collisions.
Full Explanation
Parks reservations need a write-time collision check against existing rows. A trigger can compare the new booking’s facility_id and time range with existing reservations and reject the insert with an error when the ranges overlap. Because the check runs at the database, it applies to bookings from every client—kiosk, web, or batch—rather than relying on each application to run the same overlap query; a trigger typically checks updates as well. A SEQUENCE guarantees unique numeric values, not non-overlapping wall-clock bookings for a facility, so two sequence numbers can still correspond to overlapping reservations. An external table listing park maps provides external data for reading but does not participate in booking writes or reject overlaps. JSON_ARRAYAGG combines values into a JSON array for reporting, queries, or exports; it does not block overlapping inserts. Exam caveat: the key distinction is that overlap enforcement is a data-integrity rule applied during writes, not a numbering or aggregation feature. Practical check: insert a 10:00–12:00 booking for a facility, then attempt an 11:00–13:00 booking for that same facility and confirm the trigger rejects it; a 12:00–13:00 booking should succeed if the ranges do not overlap.