4 ms·
The combination of postgres's range types[1] and exclusion constraints[2] allow you to do this safely. My 'primary key' constraints look something like: AL
by subleq 13y ago
The combination of postgres's range types[1] and exclusion constraints[2] allow you to do this safely. My 'primary key' constraints look something like:
ALTER TABLE foo ADD CONSTRAINT temporal_pk EXCLUDE USING GIST (
identity_id WITH =,
valid_range WITH &&
);
It'd be nice if temporal foreign keys were supported too, where the existence of contiguous child rows through the valid_range of the parent was enforced, but I've had to use a trigger for that.
[1]: http://www.postgresql.org/docs/9.3/static/rangetypes.html http://www.postgresql.org/docs/9.3/static/rangetypes.html
[2]: http://www.postgresql.org/docs/9.3/static/ddl-constraints.html#DDL-CONSTRAINTS-EXCLUSION http://www.postgresql.org/docs/9.3/static/ddl-constraints.ht...