I have a scenario where: there are two (or more) tables that represent independent items. lets say Users and Companies
Both of these tables need addresses stored. Each one can have one or more address
In a normal 1 to many scenario Addresses table woudl just have a UserId or a CompanyId creating a normal 1 to many relationship.
In this case i have a few approaches i can think of
the Addresses table could have both a UserId and a CompanyId and only one would be used for each record.
2 keys could be used ObjectId and ObjectType So Object id would have a UserId or a CompanyId, and ObjectType woudl be User or Company
Create an ObjectTable and add ObjectId to Users and Companies. Addresses would then have an OjbectId
I do not really like any of these solutions. i am wondering what is the best approach here.
On another note i will most likely user linqtosql for my data access layer.