实现许多实体的Notes表的最佳方法SQL中的表

编程入门 行业动态 更新时间:2024-10-22 22:53:23
本文介绍了实现许多实体的Notes表的最佳方法SQL中的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有很多表:客户,潜在客户,朋友.. 他们都有一些笔记。

问题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中的表

本文发布于:2023-11-22 03:25:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1615796.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实体   方法   Notes   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!