SpatialDB Advisor
|
Straws in the Wind Blog Articles • Industry Best Practice? • Spatial Database Independence • 2011 Oracle Spatial Excellence Award for Education and Research • Tiling Very Large Rasters • Cloud Computing GIS and Standards (OGC/ISO) • Usefulness of Spatial Metadata as a Foundation for an Australian data.gov and other uses • Vale Professor Pieter Roelof Zwart 1941-2010 • Interview by Nestoria on Real Estate Mapping • Mapping surface area of a ruptured pipe in Oracle Spatial • FOSS4G 2009 Sydney Presentation • GIS software and Database Primary Keys • To Constrain or Not to Constrain: There should be NO Question • The Shapefile 2.0 Manifesto • Maps of War Website • Talk on Open GeoData in Australia • Boarder and District Spatial Information Group Presentation on Spatial Datbases • Presentations given by myself at the Australian Oracle Spatial Forum, Sydney, Thursday 28th August 2008 • The Sad State of SQL Spatial Standards - Take 2 • Radius Studio and ESRI (Part 2) • The Sad State of GIS SQL Standards • Microsoft to release their own spatial capability for SQL Server • Radius Studio and FDO • SpatialWare 4.9 Released • First Radius Studio Certified Practitioner • Image Catalog Tool - How To Videos • Latest article published on Directions Magazine • Image Catalog / GeoRaster Management Tools • ESRI Ireland - Many Thanks • PL/SQL Packages for Oracle Sdo_Geometry • Professor Hanan Samet • ADF and Spatial • Bouquets and Brickbats • Geomatics Degrees, Space Curves and Oracle Spatial • Non-Persistent Types • Feature Data Objects - Either/Or? • A Thank You
|
There has been some discussion over on the PostGIS email list about the use of primary keys on tables by GIS client software such as uDig, QGis, MapInfo etc. It is a discussion that comes up now and again (perennial, I suppose) especially when new users of PostGIS (or Oracle on the Oracle forum etc) start asking questions. So, what are primary keys, why are they important to database tables and GIS software, and what limitations exist? What is a primary key and its importance to a database table?
In addition, we note that a candidate key:
So, a table can have many candidate keys, composed of one or more attributes, and but that all have to be unique. Finally, from a list of unique candidate keys for a table ONE is selected to be the table’s primary key. So, depending on design.
Example of Defining a Table with a Primary and Unique Key
This table can now be opened in most GIS systems. If, however, instead of using a meaningless valued column, id, we had chosen to use just the parkname column as the primay key, no GIS client package around today would be able to work with this table even though the park name values held in parkname are actually unique.
Finally, what if the table had two or more columns in the primary key? The table would also not be able to be dealt with by most/all GIS software around today. Here is an example of a table with a two column primary key.
The only way we can work with this sort of table is to add a unique integer field (in the table following I have called it gid as in geographic-id) to them and hope that the GIS will allow you to work with the defined, unique field. (For example, ArcSDE would allow this as it simply requires a UNIQUE index on a the integer field, but MapInfo, which requires Primary Keys, may not – I do not have a copy of MapInfo to check this.)
This discussion applies to Oracle, SQL Server, MySQL etc. The limitation is not in the database product but, as is usually the case, in the GIS product. I hope this is of use to someone. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
![]()
![]() |
Comment