Subject | Foreign key without an index? |
---|---|
Author | Bob Murdoch |
Post date | 2008-11-06T02:07:25Z |
I could swear that I saw somewhere that with FB 2 you would be able to
avoid creating an index on the table the FK is defined on. For
instance:
create table Five_Row (
five_row_id bigint not null,
name varchar(20),
primary key (five_row_id));
create table Million_Row (
million_row_id bigint not null,
five_row_id bigint not null,
name varchr(20),
primary key (million_row_id),
foreign key (five_row_id) references five_row (five_row_id));
In this case, there will be an index created on Million_Row to support
the five_row_id FK. However, since there are only five possible
values, the number of duplicates in this index are going to be
astronomical. Is there a way to avoid the creation of this index?
Thanks,
Bob M..
[Non-text portions of this message have been removed]
avoid creating an index on the table the FK is defined on. For
instance:
create table Five_Row (
five_row_id bigint not null,
name varchar(20),
primary key (five_row_id));
create table Million_Row (
million_row_id bigint not null,
five_row_id bigint not null,
name varchr(20),
primary key (million_row_id),
foreign key (five_row_id) references five_row (five_row_id));
In this case, there will be an index created on Million_Row to support
the five_row_id FK. However, since there are only five possible
values, the number of duplicates in this index are going to be
astronomical. Is there a way to avoid the creation of this index?
Thanks,
Bob M..
[Non-text portions of this message have been removed]