From: Todd Benson Date: 2008-07-01T01:29:41+09:00 Subject: Re: Tables: Unnecessary duplication of id fields On Mon, Jun 30, 2008 at 11:09 AM, brian wrote: > =begin > > Hello, > > I'm fairly new to Ruby, but I am trying to understand the relationship > between database structure and models. > > My difficulty is that I have five or so tables all linked together and their > primary key column is a serial number > > The tables are a set of tables called: > > itemmasters > products > prices > subprices > imprints > etc. > > products, prices, and subprices, imprints, etc. belong to itemmasters based > on a serial number > > How can I get about linking them without having to have a column in > itemmasters for each of the sub tables? > > For instance: > > product_id > price_id > subprice_id > imprint_id > > This would be somewhat silly as they all contain the same information. > Right? > > Thank you, > > Brian Anderson > > =end While not really a Ruby or Rails question, it seems you have rows/tuples that point to a singular row in another table. In other words, reverse it. Have columns in your "subtables" that is the foreign key of the "master" one. It's possible I misread your question, though. I do that pretty frequently :-) Todd