Database Reference
In-Depth Information
How it works...
PostgreSQL table inheritance allows us to enforce essentially hierarchical relation-
shipsbetweentables.Inthiscase,weleverageinheritancetoallowforcommonality
betweenrelateddatasets.Now,ifwewanttoquerydatafromthesetables,wecan
querydirectlyfromtheparenttableasfollows,dependingonwhetherwewantamix
of geometries or just a targeted dataset.
SELECT * FROM chp02.hydrology
From any of the child tables, we could use the following query:
SELECT * FROM chp02.hydrology_polygon
See also
It is possible to extend this concept in order to leverage and optimize storage and
querying by using the
CHECK
constrains in conjunction with inheritance. For more
info, see the
Extending inheritance - table partitioning
recipe.