Click here to Skip to main content
15,895,011 members
Home / Discussions / Database
   

Database

 
GeneralRe: How to add new object DataContext ? Pin
Yanshof5-Dec-10 5:23
Yanshof5-Dec-10 5:23 
GeneralRe: How to add new object DataContext ? Pin
PIEBALDconsult5-Dec-10 7:40
mvePIEBALDconsult5-Dec-10 7:40 
GeneralRe: How to add new object DataContext ? Pin
Not Active5-Dec-10 7:53
mentorNot Active5-Dec-10 7:53 
GeneralRe: How to add new object DataContext ? Pin
Yanshof5-Dec-10 8:56
Yanshof5-Dec-10 8:56 
GeneralRe: How to add new object DataContext ? Pin
Not Active5-Dec-10 9:31
mentorNot Active5-Dec-10 9:31 
GeneralRe: How to add new object DataContext ? Pin
Yanshof5-Dec-10 9:52
Yanshof5-Dec-10 9:52 
GeneralRe: How to add new object DataContext ? Pin
Not Active5-Dec-10 11:40
mentorNot Active5-Dec-10 11:40 
QuestionBest approach to DB Design where DB entity relates to many, many other DB entities Pin
G-Tek4-Dec-10 5:36
G-Tek4-Dec-10 5:36 
We have a couple of instances where this has come up in the past and now dealing with another and thought it'd be good to get input on what everyone's best recommendation and real-world experience has been with the following scenario:

1. Consider a situation where you have a single database entity that you want to relate to many other database entities.
2. For example, a table called "CommunicationLog", which is intended to store details (comments, user, date/time, etc.) related to communication with a Customer
3. However, in addition to storing the communication details in relation to the Customer, we also want to relate these records to other entities. For example, we want to identify if this communication is related to a specific Product, a Work Order, a Sales Order, a Quote, a Contract, another Employee, etc.
4. The entity we're referring to in #1 is intended to be very generic so we want it to be in one table rather than having a table for each of the entities in #3 (eg. SalesOrderCommunicationLog, WorkOrderCommunicationLog, etc). Why do we want this in one table?
4a. Maintainability - we see no reason to create multiple tables that are doing the same thing, when the only thing that differentiates each record is what the record relates to.
4b. By allowing a communication log record to be related to multiple entities it's more powerful - we're able to identify a customer complaint, for example, not only by customer, but also with a specific work order, product, etc.
4c. Having all these details in one table makes it easier to search and cross-reference comments that may be related to multiple specific identities

So hopefully that explains what we're trying to accomplish. My question is, what is the best way of implementing this, based not only on proper database form, but also considering real-world scenarios.

Here are the two approaches we've been looking at (but if you have another idea I'd be interested to hear):
Approach 1. Add a field for each new entity that this record relates to - this ensures good database integrity, but it also means that tables, relationships, stored procedures and other code need to be added/altered every time we decide that we want the Communication Log record to relate to another entity AND it results in a table with 10+ fields, of which many may be left null for a lot of the records.
Approach 2. Create a "CommunicationLogRelated" table with fields for CommunicationLogID, RelationType, and RelationID. RelationType would be used to identify the other entity that this CommunicationLog record is related to and RelationID is used to identify the PK of the other entity. The clear advantage to this is a "cleaner" table design and much easier to add new related entities. However, we lose referential integrity. I'm also not sure if there's a performance benefit to one approach vs. the other.

I've looked for patterns, but have not had any success in finding a pattern that mimics the above scenario. I'd really appreciate feedback on this, especially if you've implemented something like it in the past.

Cheers,
Chris
AnswerRe: Best approach to DB Design where DB entity relates to many, many other DB entities Pin
Dr.Walt Fair, PE4-Dec-10 11:09
professionalDr.Walt Fair, PE4-Dec-10 11:09 
AnswerRe: Best approach to DB Design where DB entity relates to many, many other DB entities Pin
Mycroft Holmes4-Dec-10 11:53
professionalMycroft Holmes4-Dec-10 11:53 
GeneralRe: Best approach to DB Design where DB entity relates to many, many other DB entities Pin
PIEBALDconsult4-Dec-10 15:14
mvePIEBALDconsult4-Dec-10 15:14 
GeneralRe: Best approach to DB Design where DB entity relates to many, many other DB entities Pin
G-Tek4-Dec-10 15:40
G-Tek4-Dec-10 15:40 
AnswerRe: Best approach to DB Design where DB entity relates to many, many other DB entities Pin
PIEBALDconsult4-Dec-10 15:35
mvePIEBALDconsult4-Dec-10 15:35 
GeneralRe: Best approach to DB Design where DB entity relates to many, many other DB entities Pin
G-Tek4-Dec-10 15:51
G-Tek4-Dec-10 15:51 
GeneralRe: Best approach to DB Design where DB entity relates to many, many other DB entities Pin
PIEBALDconsult4-Dec-10 16:02
mvePIEBALDconsult4-Dec-10 16:02 
GeneralRe: Best approach to DB Design where DB entity relates to many, many other DB entities Pin
G-Tek4-Dec-10 16:10
G-Tek4-Dec-10 16:10 
GeneralRe: Best approach to DB Design where DB entity relates to many, many other DB entities Pin
PIEBALDconsult4-Dec-10 16:36
mvePIEBALDconsult4-Dec-10 16:36 
Questionaccessing ssrs2008 reports remotely with my systems IP without IIS [modified] Pin
vinu.11114-Dec-10 1:48
vinu.11114-Dec-10 1:48 
AnswerRe: accessing ssrs2008 reports remotely with my systems IP without IIS Pin
Mycroft Holmes4-Dec-10 11:45
professionalMycroft Holmes4-Dec-10 11:45 
GeneralRe: accessing ssrs2008 reports remotely with my systems IP without IIS Pin
vinu.11116-Dec-10 20:15
vinu.11116-Dec-10 20:15 
QuestionRemove Extra Whitespace between Words -- But Leave One Space in a Certain Location Pin
Brian C Hart2-Dec-10 4:23
professionalBrian C Hart2-Dec-10 4:23 
AnswerRe: Remove Extra Whitespace between Words -- But Leave One Space in a Certain Location Pin
Luc Pattyn2-Dec-10 4:44
sitebuilderLuc Pattyn2-Dec-10 4:44 
GeneralRe: Remove Extra Whitespace between Words -- But Leave One Space in a Certain Location Pin
Scubapro2-Dec-10 5:17
Scubapro2-Dec-10 5:17 
AnswerRe: Remove Extra Whitespace between Words -- But Leave One Space in a Certain Location Pin
Scubapro2-Dec-10 5:05
Scubapro2-Dec-10 5:05 
GeneralRe: Remove Extra Whitespace between Words -- But Leave One Space in a Certain Location Pin
NeverHeardOfMe4-Dec-10 0:42
NeverHeardOfMe4-Dec-10 0:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.