A Project has many contributors (Users) who MUST be Workspace members
How would you organise this in Postgres + ecto?
Two options I’ve considered:
many_to_many workspaces_users table + projects_users table and enforce the member constraint at insertion
use a many_to_many table between projects and workspaces_users. i.e. projects_workspaces_users, this will enforce the member constraint but feels like it will make the code more complex
Thanks! Yes, that’s option 2 in my first post. I guess I was put off because it feels complicated and will involve frequently mapping from the membership table to the user, but maybe it’s the best way?
Personally I depend on DB constraints when convenient, or when absolutely critical, it doesn’t really seem like either is true here, so I would probably just have separate associations and enforce the validation with app logic.
What about a user who contributes to a project but then tries to leave? Do their contributions disappear? Are they unable to leave because of foreign-key constraints?