Subject | Re: unique constraint vs unique index |
---|---|
Author | Adam |
Post date | 2006-12-01T11:11:35Z |
--- In firebird-support@yahoogroups.com, "Nick Upson" <nick.upson@...>
wrote:
never manually create a unique index. Such an index is implicitly
created with a declared unique constraint, but a declared unique
constraint makes it clear to other future developers that you intended
the field to not hold duplicate values, whereas a unique index may not
be so obvious. Someone could easily disable the unique index if they
considered it added no performance benefit. One is far less likely to
make that mistake when it is a constraint because it will trigger the
developer to wonder why the constraint was there.
The only case I can think of to break this rule is where you want a
unique constrained field with a descending index.
Adam
wrote:
>IIRC, unique indices preceeded the unique constraint. IMO, you should
> what, if any, is the effective difference?
>
> I recall that a unique constraint is enforced via an index so does it
> ever matter which is used?
>
never manually create a unique index. Such an index is implicitly
created with a declared unique constraint, but a declared unique
constraint makes it clear to other future developers that you intended
the field to not hold duplicate values, whereas a unique index may not
be so obvious. Someone could easily disable the unique index if they
considered it added no performance benefit. One is far less likely to
make that mistake when it is a constraint because it will trigger the
developer to wonder why the constraint was there.
The only case I can think of to break this rule is where you want a
unique constrained field with a descending index.
Adam