I've got a messy legacy db to deal with (and I cannot change the schema)
It has 3 tables I need to map that are giving me some pause: party, 
individual and organization
party 1:[0-1] individual by primary key
party 1:[0-1] organization by primary key

individual never relates to organization (even though they share key 
space) and party is expected to always relate to either individual or 
organization (at least this is what is expected if all the data is good, 
I have no assurances of this from the schema though)

Would it be better to map this as 3 entities:
Party : Entity
Individual : Entity
Organization : Entity
and have party having a property to get an individual or an organization 
or two entities:
Individual : Party
Organization : Party


There are other tables with relations to party (intending to map to 
either an individual or an organization), for example interested_party 
serves as an in intersection table between an account and a party:
account 0:M interested_party M:0 party

I am struggling to figure out which is going to make my life easier in 
the long term. On the one hand I think I will end up with:
var account = LoadAccount();
var ip = account.InterestedParties.First();
var individual = ip.Party as Individual;
var org = ip.Party as Organization;
//do something with individual or org making sure to check for null

whereas on the other I would end up with:
var account = LoadAccount();
var ip = account.InterestedParties.First();
var individual = ip.Party.Individual;
var org = ip.Party.Organization;
//do something with individual or org making sure to check for null

Is one mapping better than the other (and if so, why)? Am I missing a 
better way to do this (other than getting the schema changed)? Is there 
any obvious potholes I will find myself hitting as I go either way?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to