I have a many to many relation for: Client and Broker tables (just an example). Obviously, each client can have multiple brokers and each broker can have multiple clients. What is considered the proper naming convention for the intersect table.... is it ClientBroker...?
I usually use the names of both of the joining tables.
So, in your case, ClientBroker.
I would prefer "Clients_Brokers" (pluralizing both names to indicate many-to-many).
I prefer to distinguish between intersect tables and actual transactional tables. So, I end them with Map. So it would be Client_Broker_Map, or ClientBrokerMap.
Some programmers don't like pluralizing table names for a few reasons:
- it breaks the "is a" rule, meaning if you have a table called 'User', then each record in the table "is a" User object. This follows object-orientation rules.
- a Model class is usually named for the table where its data comes from. So if you have a User model, the record represented by the model is in the User table
This makes a lot of sense if you're in control of the entire db and business layers of the project. However, a lot of frameworks now have ORM libraries that facilitate working with tables and relationships. Those ORM libraries often have a naming syntax that should be followed to let the ORM library do most of the heavy lifting.
For example, I use the Kohana MVC framework for PHP which offers an ORM library. The ORM suggests pluralizing table names, using all lowercase names, and using underscores for many-to-many table names. So for your example, you'd have the following tables: clients, brokers, and brokers_clients (the ORM suggests alphabetically arranging table names for many-to-many tables). When creating models for these tables (extending the ORM model), you use the singular value of the table name, so the model for clients would be Client. The ORM handles the pluralization conversion. Kohana's ORM also uses an inflection library, so unusual pluralization values are handled correctly. For example, a table named 'categories' can use the model name 'Category'. Finally, if you have a db structure already implemented but want to use the ORM library, you can override the default ORM table naming syntax and give it the table name you want to use.