HABTM vs Has Many


Just wondering what the recommended practice is for creating a
many-to-many relationship between two tables when the join table must
store additional data beyond just the ids of the joined tables.

for example if you have tables, albums and artists and you wanted a
join table with an additional field "year".

so you'd have schemas:


You are looking for has_many :through relationship. Look up how to do a
has_many :through and you will find all you need. This might make the
relationships clearer: