【发布时间】:2014-10-28 18:14:44
【问题描述】:
我正在为解决方案设计数据库。我面临以下情况:
- 用户可以添加产品。该产品将属于特定操作:“SELL”、“BUY”等。
- 其他用户可以将产品标记为感兴趣。所以,我将有一个表格来生成对某事感兴趣的用户。
我正在努力决定采用哪种方法:
- 我可以为每个操作创建一个表,例如“ProductSell”、“ProductBuy”等。对于感兴趣的用户(“InterestedProductSell”、“InterestedProductBuy”等)也是如此。
```
User ProductSell ProductBuy InterestBuy InterestSell
____________ ___________ __________ ___________ ____________
Id Id Id ProductId (ProductBuy PK) ProductId (ProductSell PK)
Name Title Title UserId UserId
Username UserId UserId Date Date
```
- 我可以为所有操作创建一个表,其中有一列名为“操作”。感兴趣的用户也一样。
```
User Operation Product Interest
____________ _________ ___________ __________
Id Id Id ProductId (ProductBuy or ProductSell PK)
Name Name (Buy, sell, etc) Title UserId
Username UserId Date
Operation
```
您能否就这两种方法,甚至是我没有意识到的第三种方法发表您的看法?诸如性能、优化、维护、编码之类的事情……除了我的看法之外,我还需要其他选择。
如果有关系,我正在使用 SQL Server。
【问题讨论】:
标签: sql-server database database-design