Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to implement a Notes Table for many entities Tables in SQL

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

like image 329
John Avatar asked Aug 27 '10 13:08

John


1 Answers

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?"

like image 103
Phil Sandler Avatar answered Oct 05 '22 04:10

Phil Sandler