In third normal relational design you would have the itemmaster_id in
each of the dependent tables.
That is also what happens when you define the belongs_to has_many
relationships.
There needs to be some column in the database to relate the items.
What you bring up, each child id on the parent table is a star schema.
Otherwise you have to denormalize your data design and just stuff
everything into one table.
Rails expects the ID name to be a certain way, so if you use a
different ID you have to map those columns.
For a parent child relationship where the child belongs_to a given
parent. The default ID rais expects is parent_id.
For HABTM relationships you would need to create an intermediate
table.
If you are just doing a straight select from a single table try using
all lower case?
The .find method on an ActiveRecord model finds by primary key. Without mapping your primary keys (either by doing it the way Rails wants you to or by overriding the primary key using the set_primary_key method, Rails will try to find by id.
Each field in your table also gets two finders automatically created for it. In your case, you have a field called item_serial_number or something simlar… let’s call it serialnumber for this example. With that field, Rails creates two new methods on the class:
Itemprice.find_by_serialnumber(15) (“select * from itemprice where serialnumber = 15 LIMIT 1”)
Itemprice.find_all_by_serialnumber(15) (“select * from itemprice where serialnumber = 15”)
You should grab some books on Ruby and Rails though… Rails can work with “legacy” schemas but it’s much more difficult if you’re just starting out. There are a lot of database conventions that Rails expects you to adhere to.