News for hackers. Stuff that matters.
Re:Why Use Postgres? by mjevans on Sunday April 30, 2017 @03:53PM (#14233490)
Couldn't you just have a constraint based on more then one column? In fact for many applications there are different types of resources (rooms, people, etc) which you might want to be unique within anyway.
Re:Why Use Postgres? by jeltz on Sunday April 30, 2017 @08:19PM (#14234692)
You still would need PostgreSQL's exclusion constraints to handle overlapping ranges since unqiue constraints do not handle checking for overlapping ranges, only exact equality. The below example guarantees that the same room can only be booked once.

    CREATE TABLE reservations (
        room text,
        during tstzrange,
        EXCLUDE USING gist (room WITH =, during WITH &&)
    );
You could also still have two columns and use an expression.

    CREATE TABLE reservations (
        room text,
        start timestamptz,
        stop timestamptz,
        EXCLUDE USING gist (room WITH =, tstzrange(start, stop, '[]') WITH &&)
    );
Re:Why Use Postgres? by colanderman on Sunday April 30, 2017 @05:25PM (#14233934)
EXCLUDE constraints require the range to be a single value. (You could EXCLUDE over an expression based on both columns but it's nicer to have one.)
Re:Why Use Postgres? by infogulch on Monday May 01, 2017 @12:44AM (#14235621)
What do you mean by nicer? Not all drivers support range. Why is it better than an exclusion over an expression with two columns? (with simpler data types that the driver certainly supports)