Semantic Join Table Names
I've found that, perhaps especially in the Ruby on Rails and Elixir/Phoenix communities, it is common to want to name join tables in relational databases after the names of the two tables they are joining, by mashing them together.
For example, let's say you have a
users table with some people in it, and a
magazines table with some magazines in it. You want users to be able to subscribe to some of those magazines, so you create a join table to track those subscriptions. You call it
But wait a minute—what's a
user_magazine? If you walked up to someone and said, “hey, did you know that I've got a lot of user magazines?” what do you think they would say to you? Probably nothing, because they'd be too busy averting their eyes and increasing their pace in order to have this crazy person who just accosted them out of sight as quickly as possible.
user_magazines is a somewhat meaningless name for a table, because it's somewhat meaningless as a concept. What the table actually is is a list of magazine subscriptions. So just call it that.
magazine_subscriptions is much better, and even just
subscriptions would probably suffice (depending on whether there are other types of subscriptions that your application is concerned with).
Another problem with
user_magazines is that it could imply all sorts of different relationships between a user and a magazine. It could be the magazines that a user owns. Or the magazines a user has had writing published in. Or is a regular contributor to. Or something else!
So the next time you're creating a join table, think twice about calling it
table1_table2, and consider instead what the join table actually represents. Then call it that instead.