34 lines
812 B
SQL
Executable File
34 lines
812 B
SQL
Executable File
CREATE TABLE IF NOT EXISTS Tables (
|
|
-- column-def:
|
|
id INTEGER -- column-constraint:
|
|
CONSTRAINT PK_Tables PRIMARY KEY AUTOINCREMENT,
|
|
--
|
|
name INTEGER NOT NULL UNIQUE,
|
|
--
|
|
max_people INTEGER NOT NULL,
|
|
--
|
|
room TEXT NOT NULL,
|
|
-- table-constraint:
|
|
CONSTRAINT CHK_max_people CHECK (
|
|
max_people > 0
|
|
AND max_people < 11
|
|
)
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS Bookings (
|
|
-- column-def:
|
|
id INTEGER -- column-constraint:
|
|
CONSTRAINT PK_Bookings PRIMARY KEY AUTOINCREMENT,
|
|
--
|
|
id_tables INTEGER,
|
|
--
|
|
reservation TEXT NOT NULL,
|
|
--
|
|
time_reserve TEXT NOT NULL,
|
|
--
|
|
who_booked TEXT NOT NULL,
|
|
-- table-constraint:
|
|
CONSTRAINT FK_Bookings_Tables FOREIGN KEY (id_tables) REFERENCES Tables (id),
|
|
CONSTRAINT CHK_min_max_time_reserve CHECK (time_reserve BETWEEN "00:30" AND "12:00")
|
|
);
|