RE: Re: Re: how best to implement lookup table?

Best reason to use ids rather than some magic code is there is a
posibility that the code may change somewhere down the track.

e.g. if you linked order lines to an order by the order number what
happens if the customer required a change to the exisiting order numbers
(say adding a prefix or suffix). Youd have to change the order records
and the order line records (after removing contraints and then
reinstating them after the change). Using ids (something not related to
the business models) you are free to change the business rules without
affecting the integrity of you data.

My rule of thumb is to always use integer (32/64 bit) ids to join
related tables, and this id should only be used for the join (not
containing some magic business model value). It’s a RDBMS construct not
a business construct.

If you were using an OODB then you wouldn’t have the id, the
relationship would be defined through aggreagation.

Ross

That sounds good enough for me. I understand that this is the
justification for using the rails “id” column in general, but thought
for a moment that it didn’t apply in this case. I was wrong.

Appreciate the help. Thanks.

Ken