# Naming join models

**URL:** <https://www.ruby-forum.com/t/naming-join-models/53968>\
**Category:** Rails\
**Created:** [February 18, 2006, 8:03pm UTC](https://www.ruby-forum.com/t/naming-join-models/53968 "2006-02-18T20:03:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshua\_s](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@joshua\_s](https://www.ruby-forum.com/u/joshua_s)\
**Post date:** [February 18, 2006, 8:03pm UTC](https://www.ruby-forum.com/t/naming-join-models/53968/1 "2006-02-18T20:03:24Z")

</div>

I’ve been playing around with EdgeRails and checking out some of the  
new features. The one that will probably have the biggest affect on  
my designs is join models (or :through associations). For those not  
familiar with this feature, it lets you replace your habtm  
association with a pair of has\_many associations indirected through  
an intermediate model class.

Looks like good stuff. The thing that makes me cry is trying to name  
the darn join model classes. In his Pursuit Of Beauty presentation,  
DHH uses the example of an Authorship join model class to represent  
the association of an Author and a Book, and a Tagging for a Taggable  
and a Tag. Those examples are fairly readable, but I’m noticing that  
many other relationships are harder to name. I think the problem is  
trying to turn a verb-type relationship into a noun-type reification  
of that relationship.

For example, what do you call the reification of the relationship of  
a Participant to a Meeting? A “Participation”? An “Attendance”?  
What about a Student to a SchoolClass? A ProjectManager to a  
Project? Start pluralizing and things get even uglier. Naked join  
tables have their drawbacks, but at least they are easy to name.

I suppose I could name a class ParticipantEventJoin to get a table  
participant\_event\_joins. While that would make things very obvious  
it lacks a certain charm. Maybe there is a better formula for coming  
up with a standard name. Any ideas?

–joshua susser

---

<div class="post-metadata">

**Author:** ![joshua\_s](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@joshua\_s](https://www.ruby-forum.com/u/joshua_s)\
**Post date:** [February 19, 2006, 3:17am UTC](https://www.ruby-forum.com/t/naming-join-models/53968/2 "2006-02-19T03:17:53Z")

</div>

If you are seriously struggling to find a name, it could be a sign that  
your join doesn’t really need to be a model.

First, your participant/meeting example. I think what you have here is a  
case of a mis-named model. People attend meetings, not Participants. A  
person only becomes a participant once they go to a meeting.

You can always try approaching it this way. What does object x do to  
object y?

A person _attends_ a meeting.

Person \> Attendance \< Meeting

In order to attend a class, a student must enroll.

Student \> Enrollment \< SchoolClass

A project manager is assigned to a project.

ProjectManager \> Assignment \< Project

Maybe, an employee only becomes a project manager when they are assigned  
to a project:

Employee \> Assignment \< Project

In the above, as well as linking together an employee and a project, the  
Assignment model also holds details of the assignment type (developer,  
manager).

Ultimately, if you are really struggling with a name, it might just be a  
same that you don’t need a join model, all you need is a simple habtm  
relationship and a plain jane join table.

Cheers  
Luke R.

> For example, what do you call the reification of the relationship of  
> a Participant to a Meeting? A “Participation”? An “Attendance”?  
> What about a Student to a SchoolClass? A ProjectManager to a  
> Project? Start pluralizing and things get even uglier. Naked join  
> tables have their drawbacks, but at least they are easy to name.
> 
> I suppose I could name a class ParticipantEventJoin to get a table  
> participant\_event\_joins. While that would make things very obvious  
> it lacks a certain charm. Maybe there is a better formula for coming  
> up with a standard name. Any ideas?
> 
> –joshua susser

---

<div class="post-metadata">

**Author:** ![joshua\_s](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@joshua\_s](https://www.ruby-forum.com/u/joshua_s)\
**Post date:** [July 3, 2006, 5:18pm UTC](https://www.ruby-forum.com/t/naming-join-models/53968/3 "2006-07-03T17:18:43Z")

</div>

Hi,

Now that we are headed for the CRUD-for-everything interface, it seems  
like naming join models has a little more importances as the user will  
even more likely see the join model name.

Sometimes the join model is needed just to make ordering the items  
easier using acts\_as\_list in the join model. I don’t have the naming  
thing figured out yet either.

On 2/18/06, Joshua S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The thing that makes me cry is trying to name  
> the darn join model classes.

On 2/18/06, Luke R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> If you are seriously struggling to find a name, it could be a sign that  
> your join doesn’t really need to be a model.

Some examples I’ve seen with good names (all related to people):

Author \> Authorship \< Book  
Reader \> Readership \< Book  
Reader \> Reading \< Article  
Person \> Membership \< Group  
Person \> Attendance \< Meeting  
Student \> Enrollment \< SchoolClass  
Employee \> Assignment \< Project  
Person \> Registration \< Conference

Some examples I have. Any suggestions?

Product, Person \> Visualization [polymorphic] \< Images  
Category \> Categorization \< Product

A t-shirt has red or green versions with a SKU each  
Product \> ? \< Variation

A computer has a cpu and hard drive  
Product \> ? \< Part

A user as particular role permissions  
User\> ? \<Role

A user has particular additional permissions  
User \> Abilities? \< Permission

Can you add to the list?

Thanks,  
Peter

---

<div class="post-metadata">

**Author:** ![joshua\_s](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@joshua\_s](https://www.ruby-forum.com/u/joshua_s)\
**Post date:** [July 23, 2006, 7:13am UTC](https://www.ruby-forum.com/t/naming-join-models/53968/4 "2006-07-23T07:13:05Z")

</div>

On 7/3/06, Peter M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Person \> Attendance \< Meeting  
> Student \> Enrollment \< SchoolClass  
> Employee \> Assignment \< Project  
> Person \> Registration \< Conference
> 
> Some examples I have. Any suggestions?
> 
> Product, Person, etc \> Visualization [polymorphic] \< Images
> 
> Category \> Categorization \< Product

Department \> Placement \< Product

> A t-shirt has red or green versions with a SKU each  
> Product \> ? \< Variation

???

> A computer has a cpu and hard drive  
> Product \> ? \< Part

Product \> Part \< Product

> A user as particular role permissions  
> User\> ? \<Role

User \> Role \< Task

> A user has particular additional permissions  
> User \> Abilities? \< Permission

User \> Permission \< Task

Maybe I’m getting a little better at this.

Peter

---

<div class="post-metadata">

**Author:** ![joshua\_s](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@joshua\_s](https://www.ruby-forum.com/u/joshua_s)\
**Post date:** [July 23, 2006, 10:31am UTC](https://www.ruby-forum.com/t/naming-join-models/53968/5 "2006-07-23T10:31:26Z")

</div>

BTW, [http://hasmanythrough.rubyforge.org](http://hasmanythrough.rubyforge.org) is useful for generating the  
join model with unit tests etc.

---

<div class="post-metadata">

**Author:** ![joshua\_s](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@joshua\_s](https://www.ruby-forum.com/u/joshua_s)\
**Post date:** [July 23, 2006, 7:54am UTC](https://www.ruby-forum.com/t/naming-join-models/53968/6 "2006-07-23T07:54:34Z")

</div>

I posted on this same topic earlier in week:

[http://www.ruby-forum.com/topic/73517](http://www.ruby-forum.com/topic/73517)

I’m running into problems when model objects don’t represent real world  
things. My model objects (like Views → Filters → Groups) only make  
sense in the context of my app. There is no english word (especially  
not a noun) for the relationship of a View to a Filter.

I’m going with the ViewFilter class name, but I’m not thrilled about it.  
There’s no good reason it couldn’t be called FilterView. One of the  
nice things resulting from CRUD design is simplified urls. Awkward  
relationship names make for awkward urls.

In the grand scheme of things this doesn’t really matter, but it seems  
like there should be an elegant solution.

---

<div class="post-metadata">

**Author:** ![joshua\_s](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@joshua\_s](https://www.ruby-forum.com/u/joshua_s)\
**Post date:** [September 21, 2006, 12:27am UTC](https://www.ruby-forum.com/t/naming-join-models/53968/7 "2006-09-21T00:27:14Z")

</div>

Interesting how you find a useful conversation like this AFTER you have  
resolved your problem.

Im starting a list of example join tables for RESTful applications, ive  
showen my approach and listed some of the examples from the comments  
above.

> **[Ruby on rails](http://railsnotes.blogspot.com/)**
>
> Rozwiązania częstych problemów.

’ Naming join models for RESTful applications ’
