Subject Re: [firebird-support] binary or string?
Author Helen Borrie
At 10:22 PM 10/12/2004 -0700, you wrote:

>I'd like to use an 8-bit binary object as a primary key but I'm wondering
>what the most efficient way to store this is and how indexing will be
>affected.
>
>The object can be expressed as a 16-character string prefixed with "0x", for
>example "0x0000A105B4C5D6F2"...so, would it be best to store it as a
>varchar? I have a middleware object written in C# that converts it to the
>appropriate values in order to increment it and manage it internally, I just
>need to know how to best store it as a PK and enforce uniqueness.
>
>Blobs are binary but obviously that isn't even an option as they are not
>indexed (from what I've read, I could be wrong?). Even if they can be
>indexed, I'm sure the performance would suffer.
>
>In SQL Server I would store them as a binary(8) object (not a blob) but I'm
>not sure what the equivalent would be in FB?

I don't know anything about this datatype or what happens to it
internally; but I think what you want is a varchar(16) or char(16)
character set BINARY (a.k.a. character set OCTETS). You might also want
first to define a domain with a check constraint to restrict the allowed
characters and enforce the prefix, especially if you will have other tables
referring to it through foreign keys.

./heLen