UML notation in Class diagram

Discussions

EJB design: UML notation in Class diagram

  1. UML notation in Class diagram (3 messages)

    Hello,

    I'd like to model a realationship between, for instance, Customer and Profile entities in my Class diagram. And I'd like to include class attributes to communicate better my design. I intend to implement both entities as Entity EJB. Which of the following options is correct for presenting a relationship between Customer and Profile in UML Class diagram:

    1) via Customer.profile and Profile.customer
    +---------------+ +-----------------+
    | Customer | | Profile |
    +---------------+ +-----------------+
    |id:long |---------|id:long |
    |profile:Profile|1 1|customer:Customer|
    +---------------+ |firstName:String |
                              |lastName:String |
                              |DOB:Date |
                              |address:String |
                              +-----------------+

    2) or via Customer.profile_id and Profile.customer_id
    +---------------+ +-----------------+
    | Customer | | Profile |
    +---------------+ +-----------------+
    |id:long |---------|id:long |
    |profile_id:long|1 1|customer_id:long |
    +---------------+ |firstName:String |
                              |lastName:String |
                              |DOB:Date |
                              |address:String |
                              +-----------------+

    In my database I would implement the relationship using id:long fields. But with UML diagram presentation I'm not sure because I've seen different appearences.

    Appreciate your help.

    Threaded Messages (3)

  2. Reply[ Go to top ]

    Hmm... UML doesn't guarantee the display of relationships for particular attributes in a class diagram, so I am not sure how you're going to draw out such connections.

    However, even if UML had such an option, the second option would definetely ring a bell for a Class diagram that represents your database model and the first option is certainly a way to go if you deal with a Class diagram in OO model.

    Alex
  3. Reply::UML notation in Class diagram[ Go to top ]

    Alex,

    Thank you for the reply. I did not intend to display the relationships for particular attributes in a class diagram. I'd like just to model Customer-Profile relationship on a Class digram. Now, I know that it is possible in UML to show such relationship using a field withing class of a type of different class. For instance, Customer will have 'profile' member of type 'Profile'. But if I'm dealing with EJB Entity Beans, I can imagin implementing this by saving 'id' of 'Profile' in 'profile_id' column of CUSTOMER table. With CMP, Customer Entity Bean will have 'profileId' field of type long.
    So, what should I draw on the Class Diagram?

    Thank you.
  4. Reply[ Go to top ]

    Leonid,

    I am still uncertain of what exactly do you need your class diagram for. If the main purpose is to describe your architecture or to reverse-engineer, you'd better use object names instead of primitive types. If you want to display your database relationships (as an alternative to the E-R diagram) where each class represents a database table - you should stick with primitive types as a class attribute types.

    Hope it helps.
    Alex