Hello i would like to have some advice. I m trying to learn UML modelling and i would like to model my application. I have two class diagram, User and AdressBook, and i made a composition link from User to AdressBook as all user contain an adressbook instanciated within the constructor, and i made an association link from AdressBook to User. My adressbook contains a collection of User. - Is it alright to have two different links between two classes ?
Yes, it's alright to have more than one link between two classes. Your first association means: 'has a' (user has address book) And if you read it in the other direction: 'owned by' (address book is owned by user).
Your second association means 'lists' (address book lists user) And in the other direction 'listed in' (user is listed in address book).
Regards, Jan [ August 14, 2007: Message edited by: Jan Cumps ]
It would be interesting to know more about the context (at least, just because an �address book� probably would be composed of �address�) You have many options: If the relationship is ONLY between users, a self referencing association would be enough. Something like (in UML ascii ):
If the addressBook could be used by other objects, you will need a separate address book class. If is really an address book or contact information you can extract that information from the user class into a address/contact info class:
At low level design/ implementation level, circular dependencies between classes (A depends on B and B depends on A) are harder maintain and usually avoided. Bottom line: depends on what are you trying to do
those will be my tables in my database. Is it a good model ? Thank you for any improvements, advices, help. [ August 19, 2007: Message edited by: d dddd ]
Joined: Aug 11, 2007
Sorry i made some mistakes in my previous post. For my database i have a table user with id_user as PK, a table contact who is a user with PK compose of, 2 foreign key, id_user from the user who add this contact and id_contact which is the id_user of the contact. A table addressbook. I need help for this table as i dont really know how this table should be related to user and contact in terms of primary key and foreign key. Can someone help ? Thank you.
Joined: May 26, 2007
Again, depends... Are you planning to have any extra information about the addressbook itself (or the user can have more than one)? If no, you don't need the actual addressbook table, you have: (this will be equivalent to the first "UML" diagram I posted) addressbook(parm_user_id)= select id_contact from contact where id_user = parm_user_id
If you need a separate addressbook, you need to change your model:
As any good OO practitioner would say, the difficulty you have with the relationships of addressbook is because you still need to refine the concept of what do you want to represent.
(And, by no means I'm implying I'm a good OO practitioner! )
Joined: Aug 11, 2007
Hello and thank you for your reply. I actually dont need to have this adressbook represented as a table, but i thought it would be good to have it. And in my case having the table adressbook makes things more complicated. So i'll make it simple by just having a user table and a contact table. Is dao design pattern the best way to implement a crud application ? Is there any other design pattern for this ? dao pattern is part of J2EE design pattern, is it ok to use it for other application like a swing application ? Thank you .