我最初的意图是为MongoDB提出这个问题,但我很快意识到这个问题可能适用于其他面向文档的数据库,如CouchDB等。我很难围绕构建支持定制产品的产品目录。以下是目录的一组基本目标:
最终,要弄清楚最困难的部分是产品条目的一般架构。我应该按照以下方式做点什么:
{
"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"
}
]
}
我遇到的问题是,这使得在不过度冗余的情况下限制其他选项有点尴尬。有什么想法吗?