Chapter 07

Database Management

The engine of GIS. Learn how to organize spatial information, perform complex queries, and link tables together through relational joins.

At a Glance

Prereqs: Chapter 05 Time: 25 min read + 30 min practice Deliverable: Joined table + short interpretation

Learning outcomes

  • Explain keys and relationships (one-to-many) in GIS tables.
  • Perform a join and verify the result.
  • Write one interpretation based on a query or summary.

Key terms

primary key, foreign key, join, query, null, domain

Stop & check

  1. What is the most common reason a join produces many nulls?

    Answer: The key fields do not match (type/format/values).

    Why: Joins require exact matches; '001' is not the same as '1'.

    Common misconception: The software is broken; usually the identifiers are inconsistent.

  2. Why store acquisition date and cloud percent for imagery scenes?

    Answer: To filter and reproduce your analysis.

    Why: Time and quality strongly affect RS results.

    Common misconception: A composite is one image; it is a documented set of choices.

Try it (5 minutes)

  1. Write one query you would use to filter out low-quality data.
  2. Explain what null means in one sentence.

Lab (Two Tracks)

Both tracks produce the same deliverable: a small table summary (counts/means) plus a 6-sentence interpretation.

Desktop GIS Track (ArcGIS Pro / QGIS)

Create a table, join it to a layer, and compute one summary (count/mean) by category.

Remote Sensing Track (Google Earth Engine)

Attach metadata properties to features (date/class) and compute a grouped summary using reducers. Explain the result.

Common mistakes

  • Joining on non-unique fields.
  • Mixing numeric and text IDs.
  • Not checking row counts before/after joins.

Further reading: https://gistbok-topics.ucgis.org/UCGIS

The Relational Model

In a GIS, geometry is only half the story. The Attribute Table contains the actual information about those features. These tables are organized using a Relational Database Management System (RDBMS).

🔑 The Primary Key: Every row in a GIS table must have a unique identifier (often called an FID or OBJECTID). This allows the software to link a geometric shape on the map to a specific row in the database.

Table Joins: Linking Information

One of the most powerful tasks in GIS is a Join. By matching a common field (the "foreign key") in two different tables, we can temporarily append information from a standalone table to our spatial features. This is how we map things like Census data or health statistics.

Professor's Warning

The "Data Trap": Managing Legacy Files

In the professional world, you will inevitably encounter the "Shapefile." It is the dinosaur of GIS formats—ancient, clumsy, but somehow still alive.

⚠️ The "One File" Myth

A "Shapefile" is not a single file. It is a mandatory collection of at least three files (.shp, .shx, .dbf) and often many more (.prj, .xml).

The Trap: New analysts often email just the .shp file to a client. The client tries to open it, and it fails. This is the fastest way to look like an amateur. Always zip the entire folder!

The Future is Text

While Shapefiles dominated the massive desktop computers of the 90s, the modern web (and AI!) runs on text. Formats like GeoJSON and CSV are just simple text files that can be read by any computer, phone, or website. They don't require specialized drivers; they just need to be read.

  • Shapefile: Binary blobs, 10-character limit on column names (from 1980s dBASE standards!), easy to corrupt.
  • GeoJSON: Human-readable text, web-native, flexible structure. "Just add 'Geo' to JSON."
-- SPATIAL DATABASE CONSOLE --

Available Table: `Cities` (City, State, Population)

CityStatePopulation
💾

Regional Decision: The Hospital Database

You are designing a database for Alachua County health inspectors. You have three datasets: 1) Hospital Locations (Point Data), 2) Staff Directories (Excel), and 3) Patient Satisfaction Surveys (PDFs).

The Task: You need to create a map showing which hospitals have a "High" satisfaction rating but "Low" staff-to-patient ratios.

The Dilemma: The survey data is currently in a text-based PDF. Do you:

  • A) Manually type the ratings into the Hospital Attribute table?
  • B) OCR the PDF, clean it into a CSV, and perform a Relational Join using the Hospital ID?
  • C) Just label the map manually in the cartographic view?
Expert Insight: Choose Option B. While it takes more effort to set up, it creates a dynamic link. If the survey data is updated next year, you simply swap the CSV, and your map updates automatically. This is "Data Normalization."
🛑 Critical GIS: The Danger of NULL

In a database, NULL means "unknown." It is NOT the same as 0. If you average a column where half the values are NULL, the computer ignores them. If you treat them as 0, you drag the average down artificially.
Example: If a neighborhood doesn't report crime data (NULL), a heatmap might show it as "Safe" (0 crimes). This is a common source of algorithmic bias.

Summary of Big Ideas

  • Attribute Tables store the "what" for every "where."
  • Primary Keys ensure every feature is unique and provides a reliable anchor for joins.
  • Table Joins are temporary, dynamic links between spatial data and standalone tables.
  • SQL (Structured Query Language) is the universal standard for interacting with geographic databases.

Chapter 07 Checkpoint

1. To successfully join an Excel spreadsheet to a spatial layer, both must contain:

A common field with identical values (e.g., FIPS codes).
The exact same number of columns.

2. In SQL, what command is used to filter records based on a specific condition?

SELECT
WHERE

Chapter Glossary

Schema: The formal structure or design of a database, defining fields and types.
RDBMS: Relational Database Management System—software like PostgreSQL or SQL Server.
FIPS Code: Federal Information Processing Standard—the "Gold Standard" join key for US geographic data.
← Chapter 06: Georeferencing Next: Chapter 08: Map Output →

BoK Alignment

Topics in the UCGIS GIS&T Body of Knowledge that support this chapter.