Subject | Re: [firebird-support] avoiding duplicates |
---|---|
Author | Ann W. Harrison |
Post date | 2005-07-11T21:48:15Z |
Jason Dodson wrote:
not point out that the syntax listed doesn't work... but...
Alter table Company
Add constraint CK_NAME check (not exists (select first 1 c2.name from
company c2 where upper (c2.name) = upper (name)));
The cost of that operation goes up directly with the number of records
in the table as the upper operation can not use an index. You have to
read the entire table to store a record. Not good.
like to know which rule of normalization is violated by adding an upper
field to the table.
Cheers,
Ann
>Being the well known mistress of the inexact syntax, I probably should
> Add a check constraint:
>
> Alter Table Company
> Add Constraint CK_NAME Check (Not Exists (Select Distinct Upper(Name)
> from Company));
not point out that the syntax listed doesn't work... but...
Alter table Company
Add constraint CK_NAME check (not exists (select first 1 c2.name from
company c2 where upper (c2.name) = upper (name)));
The cost of that operation goes up directly with the number of records
in the table as the upper operation can not use an index. You have to
read the entire table to store a record. Not good.
>Being (in addition to sloppy with syntax) something of a pedant, I'd
> Now, I would imagine on a rather large table, this would get slower to
> store as the record number increased, but it saves you from doing
> something silly.... like adding an UPPER field and denormalizing your
> database.
like to know which rule of normalization is violated by adding an upper
field to the table.
Cheers,
Ann