Question : foreign key problem

The simplest things are always the hardest, right?

Why can't I create two foreign keys from one table to the same primary of another?

Memberships.id(P)----(F)Map_Membership_Network.fk_pmember_id
Memberships.id(P)----(F)Map_Membership_Network.fk_cmember_id

I get:

'Memberships' table saved successfully
'Map_Membership_Network' table
- Unable to create relationship 'FK_Map_Membership_Network_Memberships1'.  
Introducing FOREIGN KEY constraint 'FK_Map_Membership_Network_Memberships1' on table 'Map_Membership_Network' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Could not create constraint. See previous errors.



there shouldn't be multiple cascade paths with that!  you have:

Memberships--\
                       >--->Map_Memberships_Network
Memberships--/

they both go in the same direction, so what's the issue here???

Answer : foreign key problem

From what you describe I am not convinced you need 2 tables.  Looks like you need recursive table....but you will need to set up highest level member to point to itself...

For the following example, I assumed that a member may belong to several networks

network: networkid
member_network: member_networkid, memberid, networkid, member_network_parentid  --> points to member_networkid
member: memberid, member_last_name, member_first_name

to get a count of people that belong to a specific member in a specifc network you may still have to do some coding...
Hope this helps...
Random Solutions  
 
programming4us programming4us