Joining tables in databases
If you use a database (SpatiaLite or PostGIS) to store your data, vector and nonspatial, then you also have the option of using the database and SQL to perform tables joins. The primary advantages of this method include being able to filter data before loading in the map, perform multitable joins (three or more), and have full control over the details of the join via queries.
Getting ready
You'll need at least two layers in either a SpatiaLite or PostGIS database. These two layers need at least one column in common, and the column in common should contain unique values in at least one table. In this case, our example uses the census_wake_2000
polygon layer and census_wake_2000_pop.csv
.
How to do it…
Open the DB Manager plugin that comes with QGIS. You can find this in the Database menu.
Select your database from the tree on the left-hand side, use
cookbook.db
in SpatiaLite (which was created in Chapter 1, Data Input and Output).Tip
If you don't see this database listed...