Last Updated: 2022-12-01
In Project S, we had tickets which were used to book appointments. Initially I
set the ticket boolean column
true when a booking was made (but never
tracked which ticket was used for which appointment).
Later requirements meant this info needed to be tracked so I added a
field to appointments. This had the side-effect that the
used boolean was
redundant, since the same info was available via the
ticket_id and a query of
SELECT * FROM tickets WHERE NOT EXISTS ( SELECT ticket_id FROM appointments WHERE tickets.id = appointments.ticket_id )
I sort of saw this coming and I should have went with my gut to use the foreign key (FK) instead of the boolean.
In most use-cases for standard web-apps it's more useful to have
with a timestamp than a simple boolean.