I have a PostgreSQL/PostGIS database with a base table (Pois_points
) and two subtables which constitute a many-to-many relationship with the base table, as you can see on the picture below (click on Many to many relationships).
I want to build a QGIS form that depicts this relationship between the tables when adding and editing items. I have seen examples of a one-to-many relationship in QGIS, which is relatively easy. But many-to-many is not documented or maybe not possible at all?
Best Answer
If you don't mind having a bit of bad design in your database, you can create the relation between your Pois_points and History tables using the relational value widget and check "allow multiple selections". You'll have to create a new column in your Pois_points table in which foreign keys will be stored as varchar arrays.
If you want a clean N:M relationship you can try this solution but you'll have to write some Python.
Since this pull request it should now be possible to create N:M relationship in QGIS easily. Documentation can be found here.
Unfortunately I can't make it working so I opened a ticket.