0

I am working on a project which involves building a social network-style application allowing users to share inventory/product information within their network (for sourcing).

I am a decent programmer, but I am admittedly not an expert with databases; even more so when it comes to database design. Currently, user/company information is stored via a relational database scheme in MySQL which is working perfectly.

My problem is that while my relational scheme works brilliantly for user/company information, it is confusing me on how to implement inventory information. The issue is that each "inventory list" will definitely contain differing attributes specific to the product type, but identical to the attributes of each other product in the list. My first thought was to create a table for each "inventory list". However, I feel like this would be very messy and would complicate future attempts at KDD. I also (briefly) considered using a 'master inventory' and storing the information (e.g. the variable categories and data as a JSON string. But I figured JSON strings MySQL would just become a larger pain in the ass.

My question is essentially how would someone else solve this problem? Or, more generally, sticking with principles of relational database management, what is the "correct" way to associate unique, large data sets of similar type with a parent user? The thing is, I know I could easily jerry-build something that would work, but I am genuinely interested in what the consensus is on how to solve this problem.

Thanks!

4

1 回答 1

1

我会看看这篇文章:实体属性值数据库与严格的关系模型电子商务

我一直看到这样做的方式是为存储通用字段的库存制作一个基表。产品 ID、产品名称等。

然后你有另一个具有动态属性的表。一个非常流行的例子是 Wordpress。如果您查看他们的数据模型,他们会大量使用这个想法。

这种方法的好处之一是它很灵活。主要的缺点之一是它很慢并且可以生成复杂的代码。

我将放弃使用文档数据库的替代方法。在这种情况下,每个文档都可以有不同的架构/结构,您仍然可以对它们运行查询。

于 2013-08-30T17:58:23.500 回答