views:

125

answers:

3

Consider two tables transaction and category each having their own ID and information.

A transaction can have more than one category, I have read creating a 3rd table to link transaction and category using their IDs is best. But what would you call this table, assuming you would have many like it?

transactionCategories is the best I'm coming up with, is there anything better?

A: 

TransactionCategories is just fine. There probably isn't anything "better", just different.

At times in the past, when I have created a table that just has the two foreign keys it needs to resolve the many-to-many, I append "Xref" to its name, which gives a clue that it doesn't have any attributes. It's just there to resolve the many-to-many.

Corey Trager
The "xref" suffix would be annoying if you later decide to add an attribute to the table. You may have to revisit lots of code.
WW
I don't rename stuff to be consistent. My biggest trouble is that I cannot remember my own conventions, and it's especially bad working in a mixed technology environment C++/C#/SQL/javascript... Is it myInt, MyInt, nMyInt, MY_INT.... can't remember!
Corey Trager
A: 

I usually use the same approach, the plural helps distinguish it as a relation table, and it contains both names so it's clear which tables.

Turnkey
+2  A: 

My naming scheme for these is to use the terminology of the domain for the interaction if there is one (eg. not student_class, but enrollment). When there is no such terminology, then you fall back onto transaction_category or category_transaction whichever sounds better.

Also, I always name my tables in the singular (e.g. student and not students).

WW
Thanks, when I used plural I think it was for the reason Turnkey mentioned. It lets it stand out that it is a relation table where one can have many.
he_the_great