views:

28

answers:

1

Hi,

I was often directed to this blog site when I was researching on NHibernate and a lot of times I got my answers. I have a question today. I appreciate any assistance.

What I am facing now is this: a simple mapping table in our database has foreign key references to three tables. The three referenced tables are: State, Organization and InsuranceProgram. The structures of the three tables are:

State

 1. StateId PK
 2. List item

StateShortName

Organization

 1. OrgId PK
 2. OrgName

InsuranceProgram

 1. ProgId PK
 2. ProgramNam

The mapping table structure looks like this:

StateOrgProgram

 1. RecId PK 
 2. StateId FK 
 3. ProgId FK 
 4. OrgId FK

I know how to and did map many to many relations between TWO tables such as the typical Products and Orders kind but not sure what is the best way to map what I call the "three-way many to many relationship".

Hope I have made my question simple and clear but please let me know if not.

I did quite some googling but didn't get anything related. Any help is greatly appreciated!

John

A: 

It's not a many-to-many any more. Your StateOrgProgram now actually needs to be mapped as an entity in its own right, with each object having a one-to-many relationship to it.

David M
Thanks, David for the quick response. I thought that might be the case. Good your answer reassured me but Let me give a try now and I will report back on how it goes.
John
You are right, David. Just map it as a normal entity with three many to ones. Thanks!
John

related questions