views:

49

answers:

5

We have 2 object types and want to connect them N:N. For example, articles & authors.

  1. How would you name relations table?
  2. What would you put first at table name, articles or authors? (articles2authors or books2authors)

Someone would, probably, recognize this question as stupid. I don't think so because I'm looking for ideal naming convention.

Thank you.

+1  A: 

Choose any

  • Junction Table
  • Cross-Reference Table
  • Bridge Table
  • Join Table
  • Map Table
  • Link Table

, but please do not use '2' to replace 'to', which is so 1970.

I personally prefer Junction: AuthorsArticlesJunction, AuthorsBooksJunction. I put Authors first because without an author neither article, nor book would not exist. This is somewhat metaphysical, but works for me.

Anton Gogolev
+1  A: 

1) article_has_author (just my "privat" convention)m or ArticleAuthor 2) in n:m relations it normaly doesnt matter.

Rufinus
+1  A: 

I prefer map - so something like AUTHOR_ARTICLE_MAP, when used consistently, explains how the table is used.

chris
+2  A: 

I'd use AuthorArticle. Generally the 'primary' object should go first (if one can be determined), but the ordering is not a big deal.

rosscj2533
The only problem I have with this approach is that it doesn't identify the table as anything special, which is why I like my "special" tables to have a common ending - i.e. MAP, JOIN, etc. I find it does help, especially when you have to come back to something 6 months later.
chris
Yeah, that is true, adding some common value can help identify the table as one of the 'N:N'/associative tables. For me, I am used to one of those table being named with the Object1_Object2 syntax. Even if the name of the table isn't identifiable as a 'N:N' table (which it should be when it's made up of two major objects), a quick look at the table structure and seeing fields author_id and article_id should make it clear. It just comes down to personal naming preference.
rosscj2533
A: 

Depends on the logical relations , for example:

  • Article_Author
  • Links , UserRoles -> LinksForUserRoles / Links_For_UserRoles
  • User , Role - > UserRole
YordanGeorgiev