I need to design the structure of the tables with the product data to meet the following requirements:
- A product consists of the following fields: EAN, CN, description, pvp
- There are several types of users that access the products. The user types are not stable, they can be added or deleted at any time.
- Any of the fields of the products may vary depending on the type of user who views it. For example:
We have three users:
- 1 - John - guest
- 2 - David - client
- 3 - Vicent - vip
We have this product with this data by default:
- 8470001234567 - 123456 - Iphone X - $799
Guest users instead of seeing this data see the following:
- 8431239876547 - 987654 - Iphone X - $849
The client users see the data by default and the vip users see:
- 8470001234567 - 654321 - Iphone X Sale - $709
This means that a user sees the default data of a given product unless there is an exception for its type. The exception can affect any field (except the id).
I can think of this structure:
- PRODUCTS: id, ean, cn, description, pvp
- PRODUCT_EXCEPTION: product_id, user_type_id, ean, cn, description, pvp
I have verified that with this structure many queries are made, do you think of a way to optimize this so that it is not necessary to make so many queries?
Note 1: the products are contained within offers that have a certain number of products. Note 2: I use Laravel. The offer model has a relationship with products, that is, I obtain the products in the following way: $offer->products()
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2FWRPCT
via IFTTT
Aucun commentaire:
Enregistrer un commentaire