Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: Dave_Bullet on January 14, 2009, 06:33:28 am
-
I have a many to many relationship between 2 classes. I need to be able to define extra attributes on the "join", so when EA does a transform from the logical to physical (DDL) model, the join table has the attributes.
I've tried an association class - but this isn't created with the PK/FKs of the 2 classes to be joined.
Is there a way to add "join" attributes at the logical level that will be generated in the DDL model?
Thanks,
David.
-
I've tried using the association class in a Class model as well and also noticed that it is not 'transformed' into the DDL. So I am not sure if I am using it properly - or if in fact this is the intended behaviour in a Class Model.
What I have done in my model is expicitly add a "join" class into my model. E.G. In a case where Class A has a Many to Many relationship with Class B, I have created a Join Class that I call A_B_Join. I then specify the multiplicity on the association between Class A and A_B_Join as 1 to many (0_* or 1_*) and likewise on the association between Class B and A_B_Join as 1 to Many. You can then add attributes to the A_B_Join class as needed. When you run a transform Package to DDL you will find that the correct PK/FK relationships have been created (the PKs from Class A and from Class B have migrated to A_B_Join) and of course the native attributes of A_B_Join will also be created.
I'm not sure if this is the right way to do this - but when I do it this way the resulting DDL looks right to me.
HTH!
-Don
-
Thanks operaman,
Dumb me. I originally tried that but got the association the wrong way around on one side of the join class (pointing from class B to to the join class, instead of correctly from the join class to B as shown below) ... hence got some funky PK/FK relationships being defined.
My original model was:
Class A (0..*) <- (0..*) Class B
Fixed as follows:
Class A (1) <- (0..*) JoinClass (0..*) -> (1) Class B
Looks like an explicit join class at the logical level is the way to go to.
Cheers,
David.
-
Yes I always have a hard time remembering this myself. Hope I was able to jog some things for you.
Cheers.