在文档数据库中创建可自定义的,按订单生产的产品目录

时间:2011-10-06 12:41:34

标签: database-design nosql

我最初的意图是为MongoDB提出这个问题,但我很快意识到这个问题可能适用于其他面向文档的数据库,如CouchDB等。我很难围绕构建支持定制产品的产品目录。以下是目录的一组基本目标:

  1. 每个产品都有一组可配置的选项。用于生产产品的材料或印刷在其上的颜色。某些选项提供其他选项,为什么某些选项限制其他选项可用。
  2. 价格因选项而异,对于某些选项而言,它是基本价格的百分比,而对于其他选项则是持平的。
  3. 还有特价的方面。我们可能与其他各种公司签订合同,为各种产品提供专门的价格。我们经常在订单和订单标题上提供促销代码和折扣。
  4. 最终,要弄清楚最困难的部分是产品条目的一般架构。我应该按照以下方式做点什么:

        {
            "Product_Name": "Test Product 1",
            "Product_Number": "P00001",
            "BasePrice":"10",
            "AvailableSize":
            [
                {
                   "Length":"1","Width":"1",
                   "PriceType":"PercentOnBase",
                   "Price":"5"
                },
                {
                   "Length":"1","Width":"2",
                   "PriceType":"PercentOnBase",
                   "Price":"6"
                },
                {
                   "Length":"2","Width":"2",
                   "PriceType":"PercentOnBase",
                   "Price":"7.5"
                },
                {
                   "Length":"2","Width":"3",
                   "PriceType":"PercentOnBase",
                   "Price":"10"
                },
                {
                   "Length":"3","Width":"3",
                   "PriceType":"PercentOnBase",
                   "Price":"15"
                }
            ],
            "AvailableNumberImprints":
            [
                {
                   "ImprintNumber":"1",
                   "PriceType":"PercentOnBase",
                   "Price":"10"
                },
                {
                   "ImprintNumber":"2",
                   "PriceType":"PercentOnBase",
                   "Price":"12"
                },
                {
                   "ImprintNumber":"3",
                   "PriceType":"PercentOnBase",
                   "Price":"14"
                },
                {
                   "ImprintNumber":"4",
                   "PriceType":"PercentOnBase",
                   "Price":"16"
                },
                {
                   "ImprintNumber":"5",
                   "PriceType":"PercentOnBase",
                   "Price":"17"
                },
                {
                   "ImprintNumber":"6",
                   "PriceType":"PercentOnBase",
                   "Price":"20"
                },                      
            ],
                "AvailableMaterials":
            [
                {
                   "MaterialName" : "Black",
                   "MaterialNumber": "M00001",
                   "PriceType":"PercentageOnBase",
                   "Price":"5"
                }
                {
                   "MaterialName" : "White",
                   "MaterialNumber": "M00002",
                   "PriceType":"PercentageOnBase",
                   "Price":"5"
                }
                {
                   "MaterialName" : "Pearl",
                   "MaterialNumber": "M00003",
                   "PriceType":"PercentageOnBase",
                   "Price":"5"
                }
                {
                   "MaterialName" : "Green",
                   "MaterialNumber": "M00004",
                   "PriceType":"PercentageOnBase",
                   "Price":"5"
                }
            ]
        }
    

    我遇到的问题是,这使得在不过度冗余的情况下限制其他选项有点尴尬。有什么想法吗?

0 个答案:

没有答案