User MANY_TO_MANY Domain
In each of these relationships they need additional attributes, so the link table looks like:
CREATE TABLE "user_domain" ( "user_id" VARCHAR NOT NULL CONSTRAINT fk_user REFERENCES user(id), "domain_id" VARCHAR NOT NULL CONSTRAINT fk_domain REFERENCES domain(id), "role_id" INTEGER NOT NULL CONSTRAINT fk_role REFERENCES role(id), "email" VARCHAR NOT NULL, PRIMARY KEY ("user_id", "domain_id")
user1 is Admin in domain1.com
user1 is User in domain2.com
So you can see I need to know the Role of the user in that Domain, and also what email address to use if I need to contact them.
My question is:
How should I structure the relations in the model in order to have access to the additional fields in the link table. Options are:
- Special notation in the User.php and Domain.php to indicate there are additional fields
- Generate a UserDomain.php model, and then have a "User ONE_TO_MANY UserDomain"
Any guidance would be appreciated...!