知识卡片
关系映射应保持命名与关联透明
对象存储场景中,尽量让表行对应对象或聚合内从属部分、外键对应实体引用,并使对象与关系表的名称及关联一致。统一语言可连接两边的概念;映射工具的能力不能替代可读性。数据库迁移不便会拖慢对象重构,但若两边长期不同步,关系含义更难辨认。原书承认性能等因素可能要求偏离,重点是偏离须明确且可解释。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第06章|Designing Objects for Relational Databases · 查看原书依据
A table row should contain an object, perhaps along with subsidiaries in an AGGREGATE. A foreign key in the table should translate to a reference to another ENTITY object.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第47章《原书第06章|Designing Objects for Relational Databases》(源文件:_epub-src/0321125215_ch06lev1sec4.html)
- 结论依据:原文给出行与对象、外键与实体引用的直观对应,并要求两种表示的名称和关联严格对应;也说明迁移成本与性能例外。
- 原始内容:A table row should contain an object, perhaps along with subsidiaries in an AGGREGATE . A foreign key in the table should translate to a reference to another ENTITY object. ... The names and associations of elements in the objects should correspond meticulously to those of the relational tables.