Subject | Re: [firebird-support] Varchar in PK |
---|---|
Author | Helen Borrie |
Post date | 2003-11-29T23:55:52Z |
At 12:57 PM 29/11/2003 +0000, you wrote:
(253 bytes or less: remember that character sets, collations and composite
indexes eat more..)
These limitations aside, mechanically, it works. So, if you have some way
of creating a unique, ATOMIC varchar value for your PK, then a varchar PK
is OK.
The deciding factor is ATOMICITY. Varchar columns are not typically
atomic. That is, they usually have some meaning as data. That usually
means humans will want to change them. To ensure data integrity, the
values in key columns should never be visible to user
applications; otherwise your database integrity is in the hands of the
worst typist in the organisation.
/heLen
>Hi,Varchar in PK, per se, no. It works, provided the index can accommodate it
>
>Is there some issue against using a varchar column in primary key?
(253 bytes or less: remember that character sets, collations and composite
indexes eat more..)
These limitations aside, mechanically, it works. So, if you have some way
of creating a unique, ATOMIC varchar value for your PK, then a varchar PK
is OK.
The deciding factor is ATOMICITY. Varchar columns are not typically
atomic. That is, they usually have some meaning as data. That usually
means humans will want to change them. To ensure data integrity, the
values in key columns should never be visible to user
applications; otherwise your database integrity is in the hands of the
worst typist in the organisation.
/heLen