What should I name a table that maps two tables together? [closed]
There are only two hard things in Computer Science: cache invalidation and naming things
-- Phil Karlton
Coming up with a good name for a table that represents a many-to-many
relationship makes the relationship easier to read and understand. Sometimes finding a great name is not trivial but usually it is worth to spend some time thinking about.
An example: Reader
and Newspaper
.
A Newspaper
has many Readers
and a Reader
has many Newspapers
You could call the relationship NewspaperReader
but a name like Subscription
might convey better what the table is about.
The name Subscription
also is more idiomatic in case you want to map the table to objects later on.
The convention for naming many-to-many
tables is a concatenation of the names of both tables that are involved in the relation. ColourShape
would be a sensible default in your case. That said, I think Nick D came up with two great suggestions: Style
and Texture
.
How about ColorShapeMap or Style or Texture.
Name the table whatever you like, as long as it is informative:
COLOR_SHAPE_XREF
From a model perspective, the table is called a join/corrollary/cross reference table. I've kept the habit of using _XREF
at the end to make the relationship obvious.