【发布时间】:2016-12-31 06:26:10
【问题描述】:
我有一个模型,它拥有许多具有多个值的属性,这些值要么代表列表,要么代表其他模型。我的研究使我考虑使用Entity-Attribute-Value design 来代表此类,但我看到更有知识的人比建议更沮丧。
让我印象深刻的是这条评论:
简而言之,当您的属性列表经常增长时,或者当它太大以至于如果您将每个属性都设为列时,大多数行将被大部分 NULL 填充时,EAV 很有用。在该上下文之外使用时,它会成为一种反模式。
基本上我的模型是student_report。根据实际形式,它具有以下属性:
- 身份证
- 创作者
- 修订历史记录
- 部门
- 参考文献
- 资金(可选、可变/不固定)
- cmets
- 目标(段)
- 范围(段落)
creator、revision history、department、references、funding 和 comments 是此表单将依赖的其他模型。
我最初的计划是创建student_report,仅使用以下内容:
- 身份证
- 创建者 ID
- 目标
- 其他段落式内容
而其他:revision history、department、references、funding 和 comments 将拥有外键 student_report_id。
对于诸如references 和funding 之类的可变/非固定模型,我计划使用中介表将student_form 连接到这些“列表”以标准化DB:
-
student_report| id | name | |----|-----------------| | 1 | Abraham Smith | | 2 | Betty Gladstone | | 3 | Chen Hong | -
references| id | name | |----|--------------| | 1 | Reference 1 | | 2 | Reference 2 | | 10 | Reference 10 | -
report_references| user_id | reference_id | |---------|--------------| | 1 | 2 | | 1 | 3 | | 2 | 10 |
我提出的解决方案是否足够?这将是一个小规模的项目,我怀疑这将需要每天使用数百次。
【问题讨论】:
标签: database forms database-design model entity-attribute-value