> Or better:
> CREATE UNIQUE INDEX permission_unique_key 
> (user_id,permission_id,department_id);
> CREATE UNIQUE INDEX permission_uninull_key (user_id,permission_id)
> WHERE department_id IS NULL;
>
> ...you may want to add WHERE department_id IS NOT NULL to the first query
> (or not).  Anyway -- this way these indexes could be used by searches 
> easily
> than using previous index I've sent.
>

 Dawid,

I see no difference of adding/not adding IS NOT NULL to the first CREATE 
UNIQUE INDEX .
So why the explicit creation of first unique index is required ?

It would be better to create unique constraint on
(user_id,permission_id,department_id) instead on explicity creating index.

Andrus. 



---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

Reply via email to