<div dir="ltr"><div dir="ltr">Kosza and list,</div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Apr 24, 2025 at 3:34 AM Kosza Antal via QGIS-User <<a href="mailto:qgis-user@lists.osgeo.org">qgis-user@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello everyone,<br><br>I want to implement the following in qgis<br><br>Given 3 geopackage tables, one is the findings, the second is the type, the third is the material, and the fourth is the findings_material. The latter is a connecting table between the type and the material. The tables refer to each other with foreign keys. The foreign key is of type uuid.<br><br>The task: in qgis, the findings table needs to be edited, the findings field refers to the type uuid with a foreign key, the material field refers to the uuid key of the material table. qgis automatically recognizes the relationships and sets up a relation reference widget.<br><br>What I want: when I select the finding, i.e. the corresponding value from the type table, in the material it should filter the values based on the pivot table.<br>This is how it looks in sql.<br><br>SELECT<br>a.uuid AS material_uuid,<br>a.values AS material_values <br>FROM<br>material AS a<br>JOIN<br>result_material AS pivot ON a.uuid = pivot.material_fk<br>WHERE<br>pivot.characteristic_fk = '6c5356d0-3257-49ed-8f95-4262d33175c9';</div><div dir="ltr"><br></div></blockquote><div>Just wondering if you could create a view based on your SELECT statement that is editable (I've not done this in SQLite so I have no idea if it's possible).</div><div><br></div>Looking at your SQL vs your description, I'm not following.  You say "the findings table needs to be edited"... Then it seems to me you need a SELECT statement like this:</div><div class="gmail_quote gmail_quote_container"><br></div><div class="gmail_quote gmail_quote_container">SELECT f.*,t.*,m.*</div><div class="gmail_quote gmail_quote_container">FROM findings AS f</div><div class="gmail_quote gmail_quote_container">JOIN type AS t ON f.type_uuid = t.uuid</div><div class="gmail_quote gmail_quote_container">JOIN material AS m ON f.material_uuid = m.uuid</div><div class="gmail_quote gmail_quote_container"><br></div><div class="gmail_quote gmail_quote_container"><div>I don't understand the purpose of the table you call "findings_material" in one place and "result_material" in another and which you say is "a connecting table between the type and the material".  It seems to me the findings table connects type and material (as per my SELECT statement).  Are you using it to restrict the combinations of type and material?  If that's the case, then you should probably relate the findings table to that restricting table rather than type and material directly.  I would probably choose to call that restricting table something like "allowed_type_material" and have a field on findings that was called "allowed_type_material_uuid".</div><div><br></div><div>Sorry that I'm not finding your problem description clear; I hope my comments don't add confusion.</div><div><br></div></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Chris Hermansen · clhermansen "at" gmail "dot" com<br><br>C'est ma façon de parler.</div></div></div>