1

The uml class diagram of a car store

Please neglect any other arrow excluding the single simple arrow on which 1..1 or anything like that is written at the end

I have refered to many websites and many books giving introductions to UML 2.0 and i came across two conventions used

when two classes are connected by a single line without arrow and either 1..1, 1..*, etc is written at the end of line, then

Assuming that at the end of line joining purchasePlan and User the term is 1..* not 0..*

1) according to one convention we create PurchasePlan object's array in User class according to diagram and one object of User in PurchasePlan

2) according to second convention we create only array of objects of purchaseplan in User, but not user's object in PurchasePlan

So which convention is the most widely used or the standard one?

2 Answers 2

1

What you are looking at there is a bi-directional association. This means convention (1) is appropriate for this relationship. If the association had an arrow then the second approach would apply.

The "0..*" is significant in that a User can have no referenced purchase plans (i.e. its PurchasePlan array can be empty). The corresponding User field in every PurchasePlan would still need to be populated (not null) in order to adhere to the bi-directional relationship; this rejects the possibility of "orphaned" purchase plans.

Sign up to request clarification or add additional context in comments.

4 Comments

i am confused now, what exactly does 1..* means if it is connected between two classes?
The multiplicity 1..* means "at least one instance". This would mean a User would always need to reference at least one PurchasePlan or more to be valid. See the link I provided: uml-diagrams.org/multiplicity.html
ok then 1..1 means exactly one instance, i was confusing it with exactly one instance of user in purchaseplan and one of purchaseplan in user or is my concept wrong?
No you were entirely right the first time. "Exactly one instance within this relationship", so just one reference in both entities. The cardinality only applies to the association line it is sitting next to.
0

The first option would create a cyclic dependency. This is discouraged because you get a higher coupling and the maintainabilty of your code degenerates. Your two options are creating a collection of PurchasePlan in your User or a single User in each PurchasePlan. Which one you use depends on your domain. Ask yourself if you have to get all PurchasePlan for a User or the other way around more often.

1 Comment

Please assume that every arrow stated is just a simple arrow stating one to one or many to one such sort of relationship not the kite shaped thing between user and session

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.