I was wondering what the best name for a linked table in this situation (or any) would be. I've searched for this, but could not find any concrete examples.

For example, I have the following tables (where 'table in the name refers to tables in a restaurant):

  • restaurant_table
  • restaurant_table_feature

A table can have all kind of features and also multiple. Think of rounded tables, tables near the window, ground-floor tables, tables near entrance. It really depends on the type of restaurant, so it needs to be customizable. Arrangements are not permanent, since tables can be moved around for various reasons. Usually, the smallest possible combination of a table has a table number, if tables are combined for a group, multiple table numbers are used.

I want to link multiple features to a table row, with a linked table. Should I call the linking table restaurant_table_feature_table or restaurant_table_to_feature.

I've seen both possibilities in multiple systems, but which one would be the preferred one?

I also could simply rename restaurant_table_feature to restaurant_feature, and create a restaurant_table_feature table as link table. However if I also have a restaurant_location table for which I would have features (which differ from the table features) I would run into problems.

To be clear, my question is what the best name would be (for the many-to-many tables) in any situation with multiple many-to-many tables.

  • FooBar is the name I would normally use. However, if I would also have a World table, and this could also have Bar's, but different 'bars' as the Foo table, with different columns. Then the Bar tables would become, FooBar and WorldBar. The linking tables would become FooBarFoo or FooFooBar and WorldBarWorld or WorldWorldBar, and this seems a little strange. – Tim May 19 '16 at 21:05

This is generally developer's choice but in my opinion restaurant_tables implies one-to-many relationship. When a table resolves many-to-many relationship I prefer names like restaurants_X_dishes. Again, this is up to my taste.

| improve this answer | |
  • 1
    So restaurant_table_X_feature in this example then? – Tim May 19 '16 at 7:18
  • If features belong to table level, not restaurant as a whole – Alex Kudryashev May 19 '16 at 14:21
  • Yes, that is correct. I'm marking this as accepted answer, as it seems to be most clear one. However I still would prefer to use _to_ instead of _X_, I think it would be better readable in a MVC/ORM environment. – Tim May 19 '16 at 21:10

I guess link table expresses some relationship, for example current feature to table availability or plans to deploy feature or history or all of them (requires more attributes besides just FKs). So it may be availability#restaurant_table_feature#restaurant_table for the first case or status#restaurant_table_feature#restaurant_table for the last one.

| improve this answer | |
  • Yes, but my question is just about how to name the link-table, in any many-to-many situation – Tim May 19 '16 at 7:17
  • I believe name should someway reflect the content this table intended for. If it's any content at all, then just m2m#restaurant_table_feature#restaurant_table – Serg May 19 '16 at 7:31

I would suggest restaurant_table_continued

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.