The name may not be entirely correct, but it describes the problem as accurately as possible. There is a field, ShopID in this field I need to make several values, for example: 1, 2, etc. I understand what to do when the field is a foreign key is impossible, but how can I solve my problem? The problem is that this field is in the product information table and the product may be in several stores.
|
1 answer
I would try to implement this by creating a link table, i.e. tables in which will be id from both tables, for example:
+------------+---------------+ | ShopId | ArticleId | +------------|---------------+ | 1 | 1 | +------------|---------------+ | 1 | 2 | +------------|---------------+ | 1 | 3 | +------------|---------------+ | 2 | 1 | +------------|---------------+ | 2 | 5 | +------------|---------------+ this way getting all the products of a particular store will be reduced to
select * from table where shopId=@shopId and getting stores with a particular position to
select * from table where articleId=@articleId |
ShopId&ArticleId. on the basis of which it will be possible to get all the goods in the store, all the stores that have this product. - Bald