CREATE TABLE operating_period (
id SERIAL NOT NULL PRIMARY KEY,
during TSTZRANGE NOT NULL,
-- other meta fields
);
Requirements: 1. No operating period can overlap with each other
Question:
- How do I add a constraint to make sure that there is no overlap in the operating hours?
- In terms of query speed, am I better off with two columns
(start_at, end_at)
or is GIST index fast fortstzrange
? - In schema design, is
tstzrange
commonly used? Or am I better of with two columns?