I am using JPA as ORM mapping. I have a booking table that currently has reservationID as its primary key. I have few more columns mainly date, fromTime and toTime.
What I want now is any other booking on the same day and conflicting with the time should not be allowed.
examples:
- 12-12-2015 10 14 -- allowed
- 12-12-2015 10 12 -- not allowed
- 12-12-2015 09 10 -- allowed
- 12-12-2015 09 11 -- not allowed
What shall I do?
- use between clause
- make date + from + to as one more primary / composite key for my table.
I am confused with both the approaches. Which one would be the better approach?