One-to-one or one-to-many association


I am creating a stock control application.
I have a table called “equipment_type” that stores a general
description of a piece of equipment. This could be for instance: Canon
60D DSLR camera.
I also have an table called “equipment” that stores all the equipment
we have with their serial numbers. There may be many Canon 60Ds and
they should refer to the “equipment_type” table for their description.
Is this a one-to-one association, because they have only one
Or is this a one-to-many, because one “equipment_type” is related to
many “equipment”

Thanks for your help

On 7 January 2012 21:12, davidwright66 [email protected] wrote:

Or is this a one-to-many, because one “equipment_type” is related to
many “equipment”

If it were one to one then there could only be one equipment object
for each type, that is what one to one means. Have a look at the
Rails Guide on ActiveRecord Associations for a good introduction to
the association types.

I would avoid the use of the word equipment for the table name. It
does not read well. Normally the table name should be the plural of
the objects in the table. equipment_item might be better, then you
can have one equipment items or two equipment_items.


From my understanding, It is more likely one-to-many relationship
because, as you already mentioned, one “equipment_type” is referenced
by many “equipment”.

In Rails perspective, they can be associated like this:
equipment belongs_to equipment_type
equipment_type has_many equipment

Hope it would be help.

Thanks very much for your reply. I now understand it has to be a one-
to-many relation. Also you are right about the name. It caused me much
confusion and I have changed it to something that pluralizes much