How to refresh my Data Table!!!!

sbaud2003

Member
Local time
Tomorrow, 00:45
Joined
Apr 5, 2020
Messages
186
Hi Sir/Madam

I have a Room Reservation database, CHECK CONSTRAINT has been applied to the RoomOccupations table to prevent double booking of the same room by intersecting ranges:
However, I am facing a problem that every time I wants to book consecutive bookings , an error message of CHECK CONSTRAINT appears as applied by me only, although there is a vacant room. For doing the same I have quit the database and re-login into it.

I don't know way its happening
 
I suggest you post a copy of the database with instructions to repeat your issue.

Sample room reservation
 
However, I am facing a problem that every time I wants to book consecutive bookings , an error message of CHECK CONSTRAINT appears as applied by me only, although there is a vacant room.
That sounds to me that your logic at the edge is not correct. It is correct when one reservation fully overlaps, it is correct when there is a a gap, but the logic is wrong when one period adjoins another period. Remember dates have a time component and sometimes this is forgotten when applying logic. Depending on how a user inputs a date, a time component besides 0 (12:00 AM) may be added.

Need to check for all the following conditions (or you can check the negation)
Period B end Greater than or equal Period A Start and less that or equal period A End (Period B ends inside A period)
or
Period B Start Greater than or equal Period A start and Less than or equal period A End (Period B starts inside A period)
Period B Start <= Period A Start and Period B End >= Period A End (B spans the whole A period)
 
That sounds to me that your logic at the edge is not correct. It is correct when one reservation fully overlaps, it is correct when there is a a gap, but the logic is wrong when one period adjoins another period. Remember dates have a time component and sometimes this is forgotten when applying logic. Depending on how a user inputs a date, a time component besides 0 (12:00 AM) may be added.

Need to check for all the following conditions (or you can check the negation)
Period B end Greater than or equal Period A Start and less that or equal period A End (Period B ends inside A period)
or
Period B Start Greater than or equal Period A start and Less than or equal period A End (Period B starts inside A period)
Period B Start <= Period A Start and Period B End >= Period A End (B spans the whole A period)
thanks a lot ... got your point, checking the details
 

Users who are viewing this thread

Back
Top Bottom