Tables relationnelles mysql
-
30-10-2019 - |
Question
Disons que j'ai 3 tables de produits, de commandes et de commandes de produits
Products Table
ID | StockNum | Description | Price
4 | 452SB | Black | 45.65
5 | 752SA | Green | 17.12
Orders Table
ID | OrderNum | Total |
14 | 12312 | 79.89 |
15 | 12313 | 45.65 |
Orders Product Table
ID | OrderID | Product | Qty |
45 | 14 | 452SB | 1 |
46 | 14 | 752SA | 2 |
47 | 15 | 452SB | 1 |
Si les informations sur le produit changent (prix ou description), cela éliminerait toutes les informations de commande précédentes, quelle est la meilleure solution pour cela ?. Est-il également plus logique de stocker l'ID du produit au lieu du StockNum?
** Mise à jour ** Est-ce que cela a plus de sens? Aussi tout ce qui est marqué d'identification à la fin est FK
Products Table
ID | StockNum | ProductDetailsID |
4 | 452SB | 8 |
5 | 752SA | 9 |
Products Details Table
ID | Description | Price
8 | Black | 45.65
9 | Green | 17.12
Orders Table
ID | OrderNum | Total |
14 | 12312 | 79.89 |
15 | 12313 | 45.65 |
Orders Product Table
ID | OrderID | Product | Qty | ProductDetailsID |
45 | 14 | 452SB | 1 | 8 |
46 | 14 | 752SA | 2 | 9 |
47 | 15 | 452SB | 1 | 8 |
Pas de solution correcte
Licencié sous: CC-BY-SA avec attribution
Non affilié à dba.stackexchange