Dealing with many to many relationships...

Questions and answers for designing and implementing forms in Servoy

Dealing with many to many relationships...

Postby JonathonBevan1342106235 » Fri Aug 17, 2012 4:49 pm

Hi

I can see many examples of parent-to-child relations in Servoy. Like "customer to invoice", "invoice to invoice lines" etc.

But in reality one can have many-to-many relationships. Like, for instance "Student to Teacher. Where a Student can have many Teachers; and a Teacher can have many Students. In this case you have to resolve the relationship with something like Teacher_Student_Usage. Where the table Teacher_Student_Usage contains nothing more than Teacher_ID and Student_ID - recording just the relationship. There is no point having a form based on the Teacher_Student_Usage table. But you would still want a Student Form with a sub-form showing Teachers and visa versa.

I can see relationships in Servoy are from ONE table to another.. So, I am just looking for some ROUGH guidance on how to implement this type of relationship in Servoy... before I start messing around...

Thanks in advance.

Kind Regards
Jonathon

JonathonBevan
JonathonBevan1342106235
 
Posts: 46
Joined: Thu Jul 12, 2012 5:17 pm

Re: Dealing with many to many relationships...

Postby rgansevles » Tue Aug 21, 2012 10:48 am

Jonathon,

Currently, databaseManager.convertFoundSet() provides this functionality, see http://wiki.servoy.com/display/public/D ... rtFoundSet

We are planning to add more support for many-to-many relations natively in Servoy.

Regards,

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: Dealing with many to many relationships...

Postby Roberto Blasco » Tue Aug 21, 2012 2:01 pm

+1

Great job for the Servoy crew
Un saludo. Roberto.

Madrid - Spain
Tfno: (+34) 625653066
E-mail: roberto.blasco.serrano@gmail.com
User avatar
Roberto Blasco
007
 
Posts: 355
Joined: Tue Apr 08, 2008 7:18 pm
Location: Madrid / Spain

Re: Dealing with many to many relationships...

Postby JonathonBevan1342106235 » Wed Aug 22, 2012 3:43 pm

Actually I did something very simple to achieve the implementation of a many-to-many. I don't know if I have done something wrong but it works perfectly.

I had a ...

Teacher Table
----------------

Teacher ID
Teacher Name
etc...


Teacher_Tutor_Usage Table (that resolved the many to many)
-------------------------------------------------------------------------

Teacher ID
Tutor ID


Tutor Table
-------------

Tutor ID
Tutor Name
etc...

I had a form for Teacher...
Then I created an INVISIBLE form that handled the relationship of Teacher_To_Teacher_Tutor_Usage table...
Then I created the Tutor form using the relationship Tutor_To_Teacher_Usage_To_Tutor...

Well this all worked without coding... I was impressed with Servoy. Now I get (when I move from Teacher to Teacher) the appropriate Students for the Teacher and they are shown in a tab.

But to be honest I am new to Servoy and there may be something wrong with this. I will study the answers that have been sent to me... No doubt I should be doing this another way... :)
JonathonBevan1342106235
 
Posts: 46
Joined: Thu Jul 12, 2012 5:17 pm


Return to Forms

Who is online

Users browsing this forum: No registered users and 9 guests

cron