This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does a "one to many" relationship mean

 
Wilson Mui
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm doing some practice exams and I came across that term, I thought "One to Many" meant one class (B) having another class (A) as a field.
so that the B would have a "One to Many" relationship to A. Because one "B" can have many "A"s But that was wrong, so now i'm trying to figure out what this means.
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let�s suppose only one program at a time can open a file for write access, but any number of programs can open a file for read access.
The write-access relationship between Program and File is 1-to-many. A program can open many files for write access, but a file can have only one opener.
The read-access relationship between Program and File is many-to-many. One program can open many files for read access, and a file can have many openers.
[ April 18, 2003: Message edited by: Marlene Miller ]
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[ April 18, 2003: Message edited by: Marlene Miller ]
 
Badri Sarma
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And i think Object class has one to many relationship with other classes, because it is the parent class for all the java classes and Object class can refer to any class in java.
 
Francis Siu
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Wilson
What does a "one to many" relationship mean?
First,it is related to Object Oriented model for UML diagram.
We assume that we have two class,one is animal class,another is Moose.
Now we can not see anyone property(For example, tail) in animal that can identify it is The Moose,it may be the dog or any other animal that has tail.Is it right?
And then,we all know that Moose Property can identify it is animal.
So, the animal class has one to many relationship to which belong to animal (or in this example,Moose.
I hope that I can explain clear in this situation.
 
Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a class diagram, multiplicities are applied to the association relationship not the inheritance relationship.
Suppose you have two classes Mailbox and Message. Neither is a subclass of the other. There is no inheritance relationship. But there might be an association �mailbox contains message�.
The �contains� relationship is one-to-many. One Mailbox *object* contains many Message *objects* and one Message *object* is contained in only one Mailbox *object*.
[ April 19, 2003: Message edited by: Marlene Miller ]
 
Francis Siu
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Marlene

The �contains� relationship is one-to-many. One Mailbox *object* contains many Message *objects* and one Message *object* is contained in only one Mailbox *object*.

humm..
you should point out the property of mail address in this case because it is primary key if and only if one person live in this flat.

In a class diagram, multiplicities are applied to the association relationship not the inheritance relationship

I total agree above statement that I am not talking about inheritance relationship in the previous example,although the example contains it
thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic