Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Wow, range types with non-overlapping constraints:

http://www.postgresql.org/docs/devel/static/rangetypes.html

CREATE TABLE room_reservation ( room TEXT, during TSRANGE, EXCLUDE USING gist (room WITH =, during WITH &&) );

INSERT INTO room_reservation VALUES ('123A', '[2010-01-01 14:00, 2010-01-01 15:00)');

INSERT INTO room_reservation VALUES ('123A', '[2010-01-01 14:30, 2010-01-01 15:30)'); ERROR: conflicting key value violates exclusion constraint "room_reservation_room_during_excl" DETAIL: Key (room, during)=(123A, [ 2010-01-01 14:30:00, 2010-01-01 15:30:00 )) conflicts with existing key (room, during)=(123A, [ 2010-01-01 14:00:00, 2010-01-01 15:00:00 )).

Used to have to rely on the application to do these sorts of constraints.



Yeah, this is another big one. I first came across the temporal project [1] in year 2008. Glad to see that it finally makes it to release.

[1] http://pgfoundry.org/projects/temporal/




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: