Re: exclusion constraint for ranges of IP

Поиск
Список
Период
Сортировка
От Samuel Gendler
Тема Re: exclusion constraint for ranges of IP
Дата
Msg-id CAEV0TzAKvCbBUYZoxfwUvmuGp8cvPUDOttyWD5W8DKvA2jWDbQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: exclusion constraint for ranges of IP  (Herouth Maoz <herouth@unicell.co.il>)
Список pgsql-sql


On Tue, Aug 23, 2011 at 1:27 AM, Herouth Maoz <herouth@unicell.co.il> wrote:
My thanks to everyone who replied.

I have decided not to implement that constraint at this time. Using a compound type will make the system more complicated and less readable, plus requires installing the package which is beyond vanilla PostgreSQL.

Now I have another exclusion constraint I'm thinking about in another and I want to verify that this will do what I mean it to do:

CREATE TABLE invoice_definitions
(
    id                  SERIAL          PRIMARY KEY NOT NULL,
    customer_id         INTEGER         NOT NULL REFERENCES customers(id),
    is_default          BOOLEAN         NOT NULL DEFAULT FALSE,
    bill_description    VARCHAR(100)    NOT NULL,
    itemized_description VARCHAR(100)   NOT NULL,
    EXCLUDE USING GIST  ( customer_id WITH =, is_default WITH AND )
)
;

Basically, each customer can have several rows in this table, but only one per customer is allowed to have is_default = true. Is this exclude constraint correct?

You can validate this yourself with 3 insert statements into the table declared in your email.


В списке pgsql-sql по дате отправления:

Предыдущее
От: Julien Cigar
Дата:
Сообщение: WITH RECURSIVE question
Следующее
От: Jasen Betts
Дата:
Сообщение: Re: Confused about writing this stored procedure/method.