Subject Re: [firebird-support] avoiding duplicates
Author Jason Dodson
OR!!!!!!!..............

Add a check constraint:

Alter Table Company
Add Constraint CK_NAME Check (Not Exists (Select Distinct Upper(Name)
from Company));

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.

Jason


Nick Upson wrote:
> In article <20050711121440.8127.qmail@...>, Max Thorne wrote:
>
>>how can I prevent a user from inserting duplicates in a table? For example I have table "company" with field "name" and a unique index for this field. However, a user can insert values like "Diesel Co.","DIESEL CO.", "diesel co.". Same company, different entries. Thanks!
>>
>
>
> Have a duplicate field, populated by trigger, that holds a case-insensitive
> copy of the name, place a unique index on that field as well.
>