Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt in domain relationship

 
pavi
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i have a doubt in domain modeeling in chapter-7 of ejb in action book.

while mentioning the relationship between the domain some are bidirectional and some are unidirectional.i am confused in this.

for example seller and item has bidirectional relationship while bidder and bid has unidirectional and order also has unidirectional relationship with other domain.

on what basis the relationship is determined.please clear me this concept.


scjp
scwcd
scbcd(preparing)
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on what basis the relationship is determined

There are two side in a relationship : a source and a target. If you declare the relationship in only one of them, it's unidirectonal. If you declare it in both sides, it's bidirectional.



Here, the relation between employees and department is only declared on the employee side, thus it is unidirectional. Department does not reference Employee. If Department was looking like the following, then the relation would be bidirectional :
 
pavi
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
thanks for your reply.i know what is uniand bidirectional relationship.
actually my doubt is that

for example both seller and item has reference to each other.Like that why cant the bid and bidder have the same but it is declared as only unidirectional.

we can say that one bidder places zero to many bids and also we can refer many bids are placed by one bidder which is bidirectional.but in the book only unidirection is mentioned and for seller and item they have given one seller sells many item and many item is sold by one seller.

please clear this doubt for me

Thanks in advance
latha
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hy cant the bid and bidder have the same but it is declared as only unidirectional.

I'll have to look at the book tonight But I guess it's a design decision. Of course, you can make it bidirectional, nothing prevents you from doing it. The example in the book just chooses to make it unidirectional (for educational reason ?). They decided that this time we didn't need to use the relation the other way around.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which page did you get that bidder and bid relation from ?
 
pavi
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

it is in pageno 252.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
252 ? All I see page 252 is table 8.1 and chapter 8.1.1.
 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have the book currently but it may be a design decision or maybe just to showcase an example of unidirectional relationship.

However it is very important to understand that unidirectional and bidirectional relationships are only present in the framework level and not at the DB level where only one type of relationship exists and that is undirectional (by foreign key).
 
pavi
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i am referring to the page in the pdf document.that is it is in chapter 7-7.1.2
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mmh... Anyway, this is just a decision/educational decision. If you want to make the relationship bidirectional, you can try it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic