File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes n-ary association Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "n-ary association" Watch "n-ary association" New topic
Author

n-ary association

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Hi,
Can someone giveme an example for nary association between classes? How do I draw this using UML.
Thanks


Groovy
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Do you mean something like the following:


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

That is binary association. n-ary meaning more than two classes are involved in the relationship.
Grady Booch UML reference talks about it but it does not give any example though.
[ September 09, 2003: Message edited by: Pradeep Bhat ]
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
I think it's still an n-ary association.
A bi-n-ary association.
regards
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

You are right, but I am looking for ternary and above.
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
what is it you would like to do, first.
Perhaps a bi-n-ary association would suffice ?
regards
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

I havent used ternary association ,so I wanna to know an example for this one and how to draw UML digaram for this.
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
I am guessing here . On a domain model with n different conceptual classes there can be n (n-1) different associations.
So 3 x 2 = 6 different associations. Quite complex for 3 classes, let alone 100s .Too many associations tend to confuse and add to the visual noise.

ternary associations are about my limit. In fact I can't find the other 3 potential associations. Best stick to associations on a "need to know basis" and leave out the ones that can be derived.
I hope I am reading the n-ary right and not confusing it with multiplicity ( 5..100 ).
regards
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Thanks Thomas!
How do I show that the above diagram represents a single association and not 3 associations.
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
How do I show that the above diagram represents a single association

You mean a un-ary association .

The students could be divided into project groups. I think that's a u-n-ary association. I thought you were into the n-aries ? When did you move to "common" language ?
Anyway, this is pure guess work. I hope an expert will correct this.
regards
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Sorry, I am a little slow in thinking today...
Here is a good example for a ternary association: http://ias.uni-klu.ac.at/projects/uml/ECOOP99/sld059.htm
What do you need it for???
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Seeing Your first diagram I feel that are are three associations i.e.
1. between school and class
2. between schooland student
3. between student and class
and *not* a single ternary asscoiation.
Is there any notation to indicate that it is a single ternary asscoiation?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Thanks HS!

What do you need it for???

I wanna to know more.
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
Gosh! It's worse than I thought.
regards
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

You link is great! It solves my query!
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
Why aren't ternary asociations that common ?
Also the note , that navigation is not shown ?
regards
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
Sorry to interrupt
I have read the notation representing the ternary asscoiation provided by Ilaj.
I have read it from the database notes,but it does not contain the word "association".
Does ternary relationship is superset of ternary asscoiation?
thanks


Francis Siu
SCJP, MCDBA
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Association is a realtionship.
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
Pradeep =.=
Association is a realtionship.
Is it more clear that association is a kind of relationship?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Grady Booch states that association is a structural relationship between classes.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by siu chung man:
I have read the notation representing the ternary asscoiation provided by Ilaj.
I have read it from the database notes,but it does not contain the word "association".

Perhaps in your database notes it's an Entity Relationship diagram? They look somewhat similar to class diagrams, if I remember correctly...
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by HS Thomas:
Why aren't ternary asociations that common ?
Also the note , that navigation is not shown ?

First, most languages don't provide direct support for this, so it's kind of an abstract thing to do.
Second, the notation is somewhat ambiguous. What would a navigation on one of the associations ends mean? Can both other classes navigate in that direction, or just one? What about multipicity?
HS Thomas
Ranch Hand

Joined: May 15, 2002
Posts: 3404
Should ternary associations be avoided then ? As it doesn't seem to translate to code , or needs to be changed severely.
So,if you find yourself drawing (or given) a ternary association , is that a signal to re-model ?
regards
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
That slide link looked what I was expecting for ternary relationship. It's probably modeled

but implemented with reference variables


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
Perhaps in your database notes it's an Entity Relationship diagram? They look somewhat similar to class diagrams, if I remember correctly...
Yes, it is exactly ER diagram
And I find it interesting that it contains Inheritance relationship syntax, and notice that using crow's foot notation. And I notice the assocation syntax is different to those sytax.
Why it is so different?
Is it different in sytax only? But how about the meaning?
thanks
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Is it different in sytax only? But how about the meaning?

I understnd that the syntaxes may be different but meaning the same.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
ER-Diagrams are about relational data and quite different from class diagrams. For example, every entity needs to have attributes identified as primary key, but can't have operations like a class.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

True there are no operations. There is no aggregation, inheritance relationship. Only thing is cardinality.
Robert Martin
Author
Ranch Hand

Joined: Jul 02, 2003
Posts: 76
Originally posted by Pradeep Bhat:
Hi,
Can someone giveme an example for nary association between classes? How do I draw this using UML.
Thanks

You draw it using a large diamond. The classes surround that large diamond and have associations to and from it. You can put a name in the diamond that represents the name of the relationship. This is very similar to the standard E-R diagram notation.
I almost never use n-ary relationships in class diagrams. When I draw class diagrams I am almost never creating data models. I use class diagrams for object models, and object models are models of behavior, not of data structure. I use N-ary relationships often in ER diagrams when doing data modeling.
An example: Employer, Employee, and Contract represent three data structures that are related to one another via an "Employement" relationship.


---<br />Uncle Bob.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Bob,
Thanks for spending your valuable time at Javaranch.
Does your book talk about ternaray relationships?
Kalpesh Soni
Ranch Hand

Joined: Jan 02, 2001
Posts: 311
Originally posted by Pradeep Bhat:
You link is great! It solves my query!

:roll:
and i could not understand anything from it !


Test 094, IBM WID 6.0 cert
SCJP 1.2
SCBCD 1.3 Beta
SCWCD 1.4 Beta
SCMAD Beta
SCDJWS Beta

KS
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Originally posted by Kalpesh Soni:

:roll:
and i could not understand anything from it !


Looks like you are a big UML expert
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: n-ary association
 
Similar Threads
Is that an association?
Place Association
Hibernate POJOs -- association or no-association ?
Association or Not
Association