mysql - Design Company -> Location -> Product Database
问题描述
I'm trying to design tables : Company -> Location -> Products tables for a project I'm working on
So basically a company has multiple locations.
Each location can have the same of different products and also products can have different prices across different locations.
So my question is, how can I efficiently design this use case because my problem is that:
If I put the PRODUCTS under the COMPANY Level --> (Product cannot have different prices etc..) but it is easy to REPORT on when doing analytics.
If I put the PRODUCTS under the LOCATION Level --> It gives me the possibility to give different prices to the same product but TECHNICALLY they are TWO different products on the database and cannot report on them easily.
Is it good to add a PRODUCT table and add another table between location and product (PRODUCT_LOCATION) that will have the price and other properties specific to a location?
Thank you for taking the time to read my question,
解决方案
您可以为 Location 和 Product 使用映射表,然后为此使用主键,您可以使用 LocationProductId 和 Price 创建一个映射表。
推荐阅读
- sql-server - 如何从表中选择一个随机 ID 并将其用于将随机数据填充到另一个表中?
- regex - 正则表达式量词不限制匹配
- wordpress - ID 的 WP_Query 参数设置
- java - Tess4J 从源代码正常工作,但不能从 JAR
- html - LinkedIn 链接并不总是显示在 Angularjs 网站上
- php - PHP PDO、Ubuntu、MDBTools 连接到 Access 数据库的问题
- node.js - 通过坐标解析 xls 文件 [Node.JS]
- mysql - macOS 上的 mysql 设置
- twitter-bootstrap - 在 scala-js 应用程序中使用 bootstraptoggle 的 onclick 事件
- c# - 将列表中的某些元素求和,该列表由 C# 中的字符串组成