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

Data modelling

 
Joseph Mokenela
Ranch Hand
Posts: 66
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have problem modelling the following scenario.

I have three tables, Member, Provider, and Receiver. The Member can be either Provider or Receiver at any pointing time, or he can be both. The only difference is that he can be provider and/or receiver to different sets of members at any one point.

How to I model this scenario?

I would appreciate your help.

Kind Regards,
Joseph
 
L Foster
Ranch Hand
Posts: 185
10
Android Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can only brainstorm with you a little. Here goes.

As a kind of alternative, think about peer-to-peer networks. There, anyone can receive. Anyone can send. Rather like what you are doing, except the distinction between sender and receiver is not quite solidified. You carry out the send/receive roles simultaneously; you have whatever characteristics are required to do either one. If a peer is not sending at the moment, it does not have to turn into something that is incapable of sending, however.

If you really still feel you need the hard distinction, consider making relationship tables between provider and member, and between receiver and member, which link members to whichever one. The receiver table (or provider) is pointed-to by a receiver_member row, and that same receiver_member row will point at a member row.

receiver_member - a relationship table containing the fields receiver_id and member_id
provider_member - a relationship table containing the fields provider_id and member_id
member - has (among other things) its member_id
receiver - has its receiver_id
provider - has its provider_id

So, you can see how those would work. This would give you Many-to-Many flexibility.
 
Joseph Mokenela
Ranch Hand
Posts: 66
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you L Foster for your insights.

I think your analogy of peer to peer networks is on point, Its make everything clearer now.

Like you have mentioned, at any point in time, the member has to be able to both act as a provider and/or receiver to any member. so there has to be that flexibility.

Kind Regards,
Joseph
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic