⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How do you handle x-n relationship?



bt101
  • profile picture
  • Member

Posted 11 December 2012 - 05:23 AM

Hi - Newbie here.
BTW - The software is very nice and allowed me to get something resembling an application in a few hours.

Assume we have 2 tables:

[b]employee[/b]
employee_id
name
etc

[b]project[/b]
project_id
leader
secretary
etc

So both "leader" and "secretary" are related to the employee table.
I want the user to have a pulldown for both "leader" and "secretary" where we can just choose one employee for each.

If I am correct, I cannot use a 1-n relation using "set_relation"? I think this is because the 1-n relation requires that the field in the project table be named employee_id (to match the key in the employee table). And I therefore can only have one field in the project table with that name (I cannot have 2 fields with the same name of employee_id in order to handle both "leader" and "secretary").

So now I am thinking I must use an n-n relation. However, if I understand the n-n relation correctly, it can relate one or more employees to the project table, but I don't think it gives any context to that relation? That is, there is no way to distinguish between "leader" and "secretary".

How do you handle this situation?

Thanks.