Is this a good db architecture and if not what can i change about it

Viewed 472

Database structure

I found this in an old post and i'm thinking of using it for a project, but i don't know if i should change it or leave it, here's what i want to change:

  • remove product options and add product id and option group id to options
  • remove order details and have it's info in orders

is what i'm doing bad? also if you could be kind to tell me some of the best practices for something like this i would greatly appreciate it.

thanks for your time.

1 Answers

Both tables are there for a good reason.

productoptions is a mapping table between options and products: this is a many-to-many relationship, where a given product may have multiple options, and an option may be used by multiple products. If you remove this table, you end up redondantly adding the optionName to each and every row in productoptions that relate to the same option, which is inefficient, and might break data integrity (how do you ensure that a given option always has the same name?).

As for order_details: this is a many to one relationship towards orders. An order may have mutliple details line, each referring to a different product. Removing this table means losing this possibility.

Related