Hello,
maybe you can help me. I am looking for a reasonable way to model the
following concept.
Assuming, we have 2 entities:
- User (table users)
- Town (table towns)
A user can, for example, add a town to the database, so we have 1:n
relationship (one user can add several towns) and the corresponding
foreign key in the town database, that’s allright. But now, let’s
suppose, that a user can optional be a kind of contact person for one
or more towns. What’s the right way to realize this?
I thought about an attributed join table between users and towns.
Since habtm doen not support attributes to be changed (as far as i
know), we could realize it through has_many :through…
But now, I ask myself if that’s the best way to model the relationship
between users and towns and I really asked myself, how to name this
join table. Normally, it’s common practice to name tables after nouns,
in this case maybe contact_persons. But I could it also name something
like “acts_as_contact_person_for” to get a bit more straight forward.
I really would like to have a good solution for this, because, I’ll
have a lot of such relations.
In conclusion: Do I generally have the right idea about that? How
would you model this? And what’s about the naming in this case? Is
there a kind of pattern for this problem?
I really thank you a lot!
Best wishes,
ms