我有很多表:客户,潜在客户,朋友.. 他们都有一些笔记。
问题1:我应该有一个Notes表与所有的父表共享。 OR 我应该有一个NotesCustomer,NotesProspects,NotesFriends表吗?
问题2: 如果最好的解决方案是第一个解决方案,那么这个通用Notes表应该有一个FK到父表,父表的类型?
我使用EntityFramework,但这个问题也是一般的我猜...
感谢 Jon
解决方案第一个选项是Prospects,Customers和Friends的独特Notes表,可能是一个更清洁的解决方案。 / p>
如果使用通用笔记表,您将需要有三个可空的FK列来确定FK属于哪个相关表,其中只有一个填充在每行中
一般来说,良好关系模型的目标不是(或不一定)将类似数据存储在一起,而只能存储特定数据一次。所以在设计这个问题时要问问自己的一个好问题是通过将所有笔记存储在同一张表中获得什么?
i have many tables : customers, prospects, friends.. They all have some Notes.
Question 1: Should i have one Notes Table shared with all the parent Tables. OR Should i have a NotesCustomer, NotesProspects, NotesFriends Tables ?
Question 2: If the best solution is the first one then this general Notes table should then have a FK to the parent table but ALSO the type of the parent table ?
I'm using EntityFramework but this question is also general i guess...
Thanks Jon
解决方案The first option, a distinct Notes table for Prospects, Customers, and Friends, is likely a cleaner solution.
If you use a general notes table, you will need to have three nullable FK columns to determine which related table the FK belongs to, with only one of them populated in each row.
Generally speaking, the goal of a good relational model is NOT (or not necessarily) to store like data together, but to only store specific data once. So a good question to ask yourself when designing this would be "what am I gaining by storing all notes in the same table?"
更多推荐
实现许多实体的Notes表的最佳方法SQL中的表
发布评论