QGIS – Managing Relationships in QGIS

personal-geodatabaseqgisrelatesspatialite

Coming from an ESRI background I'm used to ESRI geodatabases (.mdb or .gdb).
In those databases, I could create feature classes, tables and relationships between them. Every time I loaded a feature class from one of my geodatabases into a new ArcMap project, relationships were automatically loaded as well: in example, if I loaded a point file which had two related tables, the INFO feature showed me the information coming from the point feature AND from the two related tables.

I'm trying to reproduce this in QGIS. I created a Spatialite database, with the same point feature, added the two tables and created the relationships between them. I then loaded my point file in QGIS, and with the INFO tool I can only retrieve the point info, NOT the related tables too. So I loaded the tables to my QGIS project and manually recreate the relationships.

So my question is: is this the only way to do this? Every time I start a new QGIS project do I have to load the point, the two tables and recreate the relationships?

EDIT: I'm talking about one-to-many relationships, every point has two or more related rows in the related tables

Best Answer

Besides creating the relations in spatialite (by adding reference constraints) you need to inform QGIS about that relations.

If I recall well, that is done in the Projects properties, relations tab.

Once you add all layers relations to the project, you can set the relation widget in feature form and attribute table. So for each feature you can see and edit the n related features.

More details information in the user's manual:

http://docs.qgis.org/2.14/en/docs/user_manual/working_with_vector/attribute_table.html?highlight=relations#creating-one-to-many-relations

Related Question