nhibernate - problem with multiple references foreign key -


i have 4 tables :

1 - tbl_cars

id (pk) car_name model year 

2 - tbl_carowner

id (pk) carid (fk - reference tbl_cars) ownerid (fk - reference tbl_ownerpersnoal or tbl_ownercompany or tbl_ownergov)  ownertype (to make differentiation owner)  

3 - tbl_ownerpersonal

id (pk) name ic_no address 

4 - tbl_ownercompany

id (pk) registration_no business_type name address fax mail 

5 - tbl_ownergov

id (pk) agency_name 

as can see, need make differentiation between owner because of different field.

how can relate table mysql , nhibernate?

you cannot - it's against basic principles of relational database design. foreign key can ever reference 1 , 1 table - cannot have foreign key references 1 of 3 tables...

what need have 3 fk keys in tbl_carowner

owneridpersonal  (fk tbl_ownerpersonal) owneridcompany   (fk tbl_ownercompany) owneridgov       (fk tbl_ownergov) 

and preferably make sure 1 of keys if valid (not null) @ given time.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -