Does it handle intersection tables for n:n relations?

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
thetoolwiz
Posts: 8
Joined: 2016-04-04 19:59

Does it handle intersection tables for n:n relations?

Post by thetoolwiz » 2016-04-05 05:55

How does AppGini handle many-to-many relationships?

It would seem to be a fairly common need.

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Does it handle intersection tables for n:n relations?

Post by a.gneady » 2016-04-05 11:32

Many-to-many relationships should be broken into two one-to-many relationships using an intermediate table with 2 lookup fields (foreign keys), one to each of the 2 main tables. For example, if you have a students-courses application, where each course can be taken by several students and each student can enroll in several courses, this is a many-to-many relationship. To handle this, we could create an enrollments table with a lookup field to students and another lookup field to courses.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

remkop
Posts: 3
Joined: 2016-04-05 20:00

Re: Does it handle intersection tables for n:n relations?

Post by remkop » 2016-04-05 20:04

I'm also looking at this functionality.
Is appgini also providing a way to show the enrollments in one or both tables (courses or students) as a multi-select listbox?

thetoolwiz
Posts: 8
Joined: 2016-04-04 19:59

Re: Does it handle intersection tables for n:n relations?

Post by thetoolwiz » 2016-04-06 16:34

So how do you actually do it with AppGini? Do you need a separate page that has two drop-down boxes where you select ADD, then pick an item from each table, then save? Technically speaking, it should be transparent. But this would require an additional step, like an "enrollment form", although it might only work for one class per student. (Could you make it handle, say 5 or 10?)

Then how do you manage them? (Deleting one or both related records requires a cascaded delete on the intersection records. What about just deleting one "line item", which is one single intersection record?)

Usually you want to make these record insertions not just invisible, but atomic with the addition of one or both related records.

Post Reply