What are the benefits and obligations of including grandparent + foriegn keys in a table.
For example, if my object model looks below. (Significantly simplified, so it is not suitable for a reference recursive table.)
a {aId, bCollection, ...} b {bId, cCollection, ...} c {cId, dCollection, ...} d {dId}
The two data model options that come to mind are as follows:
option 1:
a {pkA, ...} b {pkB, fkA, ...} c {pkC, fkB, ...} d {pkD, fkC, ...}
option 2:
a {pkA, ...} b {pkB, fkA, ...} c {pkC, fkB, fkA, ...} d {pkD, fkC, fkB, fkA, ...}
Option 1 is more normalized, and inserts and updates will be easier, but I see that the queries are becoming quite complex, especially with many, many relationships and / or compound keys.
Option 2 complicates insertions and updates, but extracting reports will be easier. In addition, the database will be larger, but in fact it does not bother me at all, since it is quite small.
But these are pretty minor issues compared to issues that can arise with an ORM infrastructure similar to an entity. I am inclined to option 2, because I would like to access the grandchildren directly from the parent, for example:
Class A { id, bCollection, cCollection, dCollection, ... } Class B { id, cCollection, dCollection, ... } Class C { id, dCollection, ... } Class D { id, ...}
Is framework 4.0 entity handling this situation gracefully? What are the pros and cons of the two options? Is there any other alternative that I should consider?
Or simply put, how the hell does one google ask this question ?!
One more note. Like many of you, you need to rely heavily on Option A for your brush and head, but I know that I read an article in msdn that details why Option B is better. Sorry, I can not find it. :(
in advance for your thoughts.