2

Consider I have a geometry table having one-to-many relationship with a no-geometry table. When I create a feature (geometry), I would like to be able to add the relative no-geometry table data in the corresponding feature attribute edit form as well. Is this possible?

5

This is possible.

But for QGIS to support this type dynamic change when editing data, the data has to have a backend to support that like a RDBMS.

If using PostgreSQL that has PostGIS enabled, you could create a new VIEW to facilitate the requirements of the JOIN.

Then when you add a new feature to your source table (the geometries) or the view, then the VIEW will reflect that change and map the values to the related table correctly.

When creating a new feature in QGIS, you often have to "Save Edits" before the change is actually committed to the database - once the feature has been committed the VIEWS will do their thing and you should be able to see the changes (ie, the columns from the related table are populated in the VIEW)

There are a number of ways you can make sure the data you enter is valid for both the spatial and attribute components. QGIS allows you, for example, to set up the input forms so that you can enter values from a list of existing values in a column (or enter new ones if needed). But this makes sure that the data you are entering will actually map to the related tables.

Then on the PostgreSQL/PostGIS side of things, the data types can be checked against CONSTRAINTS built into the database such as making sure the column types are the right format and length, spatial types are 3D vs 2D, geometry types are consistent (eg, all LINESTRINGS or all MULTILINESTRINGS). You can even set up constraints that only allow a set of values (similar to building domains and subtypes in an ESRI File Geodatabase) to be valid for specific columns. This last little bit enhances the QGIS form building process by preventing users from inputting invalid values that won't match a record in your related table.

Though this isn't an example of JOINS, this video shows the dynamic nature of VIEWS and how they can be leveraged: http://youtu.be/oOhbbEkl4Kg

EDIT:

There are these two related questions that also give some tips on how to work with subtype and domain type functionality in QGIS.

  • Views using Joins will resolve one-to-one relationship. But how can get the one-to-many relationship? Example, "ElectricLine" geometry table has one-to-many relationship with "ElectricLineMaterial" non-geometry table. When adding an ElectricLine, user should have ability to add more than one ElectricLineMaterial records against that. Please give your suggestion. Thanks. – Vasudevan Periasamy Jan 17 '14 at 20:10
  • Check out the Data Driven Input Mask plugin. I haven't tried it, but its documentation says it can handle one to many relationships. – HeyOverThere Jan 17 '14 at 21:02
  • 2
    2.2 has support for 1:m relationshops on any data type. – Nathan W Jan 17 '14 at 21:19
  • @NathanW Looking forward to it =) – SaultDon Jan 17 '14 at 22:47
  • 1
    about 2 months, depending. – Nathan W Jan 18 '14 at 5:27
3

QGIS 2.1's Relations handles the relationship data in QGIS in a excellent manner.

Note: 2.1 is a dev version, 2.2 will be the release version.

enter image description here

  • The problem is that an identity ID is not generated in the database until the record is saved. QGIS doesn't know this ID on the form when the record is created so the children are not linked. The only workaround is to create the record, save it to the database and then re-open it for editing and adding child records etc. – Damien Jul 24 '15 at 1:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.