Re: Primary Key...Is One Required?
Posted in 1999
Bonnie
>Is it necessary to have a primary key for a table?
Not really, but if you are implementing referential integrity from another
table, then you do. In this case, it is better to create a named unique
index since that is easier to manage.
>According to Informix Documentation, if a primary key does not exist for a
table, a primary
>key is composed of all columns taken together. Does this mean that
Informix automatically
>generates a primary key?
Not as far as I know. It may be interesting to know which FM (with a page
number if possible) says this.
>Also, I recently attended an Informix Class where the instructor said that
Informix does
>not automatically generate a primary key.
I would tend to agree with him.
>I'm now wondering whether or not I should create a serial record_num
primary key for this
>table because if one is automatically generated out of every column (I
have a
>large number of columns) and because primary keys are automatically
>indexed, this will be a very large/inefficient index.
Primary keys are automatically indexed, but a PK is not automatically
generated out of evey column, AFAIK. It is interesting that you are
thinking of using serial surrogate keys instead of "natural" keys. At each
of the sites I have been to, it is one or the other, almost a religious
issue :-).
HTH
Sujit
Bonnie Annelin <bonnie_annelin@intuit.com> on 06/02/99 04:37:35 PM
Please respond to Bonnie Annelin <bonnie_annelin@intuit.com>
To: informix-list@iiug.org
cc: (bcc: Sujit Pal)
Subject: Primary Key...Is One Required?
I have a question regarding primary keys for tables. Is it necessary to
have a primary key for a table? According to Informix Documentation,
if a primary key does not exist for a table, a primary key is composed
of all columns taken together. Does this mean that Informix
automatically generates a primary key? I do a database dump (dbschema)
and do not see a primary key listed for my table. Also, I recently
attended an Informix Class where the instructor said that Informix does
not automatically generate a primary key. I'm now wondering whether
or not I should create a serial record_num primary key for this table
because if one is automatically generated out of every column (I have a
large number of columns) and because primary keys are automatically
indexed, this will be a very large/inefficient index.
Thanks,
Bonnie Annelin