Add available bookings scripts and results

This commit is contained in:
2024-11-18 15:40:17 +01:00
parent 9308f5471a
commit 0d75c1c035
5 changed files with 166 additions and 0 deletions

17
sql/table_is_free.sql Normal file
View File

@@ -0,0 +1,17 @@
-- available bookings - task 2
-- changes:
-- changed BookingDate (Reserved) data type from date to datetime, because I assumed that Little Lemon
-- allows wants bookings per day and table - a table is considered blocked for 2 hours
-- noqa: disable=CP03,LT02,RF03
create function TableIsFree(Reserved datetime, TableNumber int)
returns boolean
deterministic
begin
return (select not exists (
select BookingID
from Bookings as B
where
abs(timestampdiff(second, B.Reserved, Reserved)) < 2 * 60 * 60
and B.TableNumber = TableNumber
));
end