1

I am creating some templates in my database that users would be able to use to help set up some of their data.

For example,

I have the following tables (simplified of course):

store (id, store_name)
product (id, product_name)

product_template(id, template_name)
product_template_product (FK: product_template_id, FK: product_id)

store_product (FK: store_id, FK: product_id)

Ultimately, I am wanting a store to be able to select various products as inventory to their store from the product table. These would be linked to the store in the store_product table.

Rather than the store adding each items one at a time I am also creating a template that will allow them to do this. So for example, they may select the "dairy" template to add a all the dairy products to their store.

In this scenario, "dairy" would be the template name in the product_template table. Then each product linked to this template would be placed in the table product_template_product. So if a user selects this particular template, then all the products in that template would be added to the store_product table.

My question is about the naming of the product_template_product table. It is linking the product_template table with the product table. However, the table name ends up sounding redundant.

Am I just being too pedantic here, or is there a more preferred way to be naming such table structures? I do have a few other tables in my database where similar naming is happening due to templates being used in those places as well.

4
  • product_template_product is totally fine naming convention. It groups the tables logically when viewing them, and if you have multiple instances of this pattern, its pretty easy to work out what the tables are for
    – Trubs
    Jun 2 '19 at 21:56
  • is the product_template_product correctly specified? Should it be product_template_product (FK: product_template_id, FK: product_id) ?
    – Trubs
    Jun 2 '19 at 22:00
  • @Trubs Yes, sorry, was trying to simplify my table structure for posting here and made a mistake in the foreign key names.
    – kojow7
    Jun 3 '19 at 4:39
  • 1
    I very often use a 2 to separate the table names, e.g. product_template2product A name like product_template_product could also mean a table linking product to template_product Jun 3 '19 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.