Can I create one-to-one relationship using project relations in QGIS?

I am trying to create a spatial database in QGIS. I want to link my attribute data to my spatial data (shapefile). I have already done this using attribute join. Do I need to go ahead and define the relationship using project relations or does the join (which I already created) create the spatial database?

  • What kind of spatial database do you need to create. I suggest you start with a file based database ie geopackage and then load the individual layers into the database. Then use sql to create a view which joins the data the same way that the join is being done in QGIS. If you create the join in QGIS and save the output as a geopackage that creates a DB but if you were to update your spatial data and non spatial data you would have to create the join and save it again as another DB Jun 2 '20 at 1:25
  • I will definitely save it as a geopackage. Also I would like to make simple query. For example: which of the polygons in my layer is the smallest. OR... Which of the polygons was the first to be established? (I have year of establishment information in my attribute layer) Is there a way to do it in QGIS? Jun 2 '20 at 9:23

Simply add the layer and the CSV (Excel) file to the project (drag'n'drop), then right click on the vector layer: Properties / Joins / Add new join (+ icon),
and there you have to refer to the common attribute field.

If you want to 'save' the connection, then you can create a new a field in the Field calculator and in the Expression panel just refer to the field name of the joined field. Finally Save edits.

  • This was helpful, sorry I should've added that my attribute table is an access database. Anyway i used odbc connection to read the data and I have done the join with my shapefile in QGIS. I would like to make simple query. For example: I have five buildings in the vector layer and also in the attribute layer some services which the buildings provide... So for my query, which of the buildings is the biggest? or another query would be which building provides this service? Is there a way to do this in QGIS? Jun 2 '20 at 9:16
  • Of course, that's GIS purpose. In the mentioned Field Calculator create a new column (area), and calculate this function: $area for the buildings, then save edits. Finally you can sort the attributes according to the area field.
    – poetyi
    Jun 2 '20 at 13:59

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.