Associations typically refer to relationships between models in ORMs such as ActiveRecord.
Associations typically refer to relationships between models in ORMs such as ActiveRecord.
Typically associations are classified based on the number of associated models:
- one to many: one of the models stores the ID of the other
- one to one: models (which 'belong to') each store the ID of the one associated model (which 'has many')
- many to many: the models are linked via a join table in the database which may (called sometimes 'has many through') or may not (called 'has and belongs to many') be a model itself