On Feb 9, 2006, at 9:10 AM, Tom M. wrote:
wrote only accessed leftmost members of multicolumn indexes. In
going to be very costly.
Sorry to reply to my own post, but I just realized another HUGE
difference!
Your method of adding the foreign key into the primary key and my method
of placing a unique constraint on the foreign key (making it an
alternate
key) have entirely different semantics, and my method is more compatible
with the Rails definition of has_one than yours.
With your method, this would be allowed:
insert into table (id,foreign_id) values (1,1)
insert into table (id,foreign_id) values (1,2)
insert into table (id,foreign_id) values (2,1)
insert into table (id,foreign_id) values (2,2)
Which means that your method is doubly incompatible with Rails’ has_one
semantics:
- id is supposed to be unique in a table, period.
- foreign table has_two entries in table.
With my method, you’d get this:
insert into table (id,foreign_id) values (1,1)
insert into table (id,foreign_id) values (1,2) <- errors out (id is
not unique)
insert into table (id,foreign_id) values (2,1)
insert into table (id,foreign_id) values (2,2) <- errors out
(foreign_id is not unique)
–
– Tom M.