Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Difference: Uniq. Constraint & Index ?
On 18.10.2006 19:55, Brian Peasland wrote:
>> The basis for my question was that I've frequently read the rule of >> thumb "if it is a business constraint, use a DB constraint for >> enforcement - otherwise use an index". This seems a bit conflicting >> with your general preference of constraints. Or do you think this >> rule of thumb to be wrong?
I came across an example. Basically uniqueness was a side effect of the data being entered and the columns the index used. I think I roughly remember the basics: there was a table like
create table foo (
foo_id number primary key,
foo_item varchar2(100)
)
Now, there was a non unique index on foo_item. Since this table had many entries and there were many lookups to foo_id via foo_item the DBA suggested to add foo_id to the index as last column; that way lookups could be satisfied purely via that index and Oracle never needed to go to the table's pages. As a side effect of this, although foo_item is not unique, (foo_item, foo_id) is unique and the index was in fact made unique because of better storage characteristics.
That's roughly the story as I remember it.
Kind regards
robert Received on Thu Oct 19 2006 - 03:23:22 CDT
![]() |
![]() |