[UML] One association class for two tables(classes)
Hello,
I am creating a database schema using UML Module. It will be later transformed into classes and then I will add annotions in order to use JPA.
I got 3 tables (classes): A, B and C. Tables A and B uses some pieces of information stored in the table C. Multiplicity is set to 0..* for both cases. I mean the relationship between tables A and C is the same as between B and C - it's many-to-many (M:N).
I would like to show this relationship as a association class. While there is now problem with connecting two tables, I can't attach second table to association table.
I would like to have tables A and B associated with C throught only one table.
Is this possible?
Regards,
Stanley Styszynski
# 1
I am going to first repeat the question, so you can verify that I understand what you want. You would like to use an association class to represent an assocation between A and B. The data in class C is used to tie the class A and B together. For example you have a Cars table and a Parts Table. Now you want a table called CarToParts that has two columns: CarID and PartID. With the CarToPart table you can retrieve all CarIDs that use a specific PartID.
To accomplish this you first drop the Car and Part classes. Then you draw a association class between Car and Part. The result is an association between Car and Part, and a third class that is attached to the new association.
Now, for a different topic. In Netbeans 6 M10 we have enhanced our code generation. We now use a template based code generation. The code generation is also extensible, so you can add new templates and specify when the template will be executed. So, what that means is that you can use a stereotype like "persistence", and create a template that knows how to generate JPA code. That way you will not have to later add the JPA annotations, code generation will do it for you :)
For more information see http://wiki.netbeans.org/wiki/view/DomainModelingCodeGeneration