← Back to Index
Chapter 5

Database Concepts

Syllabus & Marks Distribution

DetailInformation
Chapter5 — Database Concepts
Teaching Hours3 hours
Marks Allocation6 marks
Total Course Marks80 marks
Weight7.5% of total

Syllabus Topics

  • Database concepts and components
  • Flat files
  • Relational database systems
  • Data modeling
  • Views of the database
  • Normalization
  • Databases and GIS

Importance & Frequently Asked Topics HIGH

Marks Distribution by Each Exam

Asked 20 times across past exams. Total marks: 84. Average marks per exam: ~6.

ExamMarks
2071 Bhadra6
2071 Magh6
2072 Ashwin6
2072 Magh6
2073 Bhadra6
2073 Magh5
2074 Bhadra2
2074 Magh4
2075 Bhadra—
2075 Magh7
2076 Bhadra6
2078 Chaitra7
2079 Chaitra3
2080 Chaitra6
2081 Chaitra6
2082 Shrawan8

Frequently Asked Topics

TopicTimes AskedFrequency
Relational Database Systems 14
Database Analysis 3
Normalization 2
Database Concepts and Components 1

Topic-wise Importance & Exam Tips

TopicImportanceKey Points / Exam Tips
Relational database concepts (tables, keys, relationships)HighDefine RDBMS, explain primary key, foreign key, and how tables are related. Draw ER diagrams.
Normalization (1NF, 2NF, 3NF)HighExplain each normal form with examples. Show how unnormalized data is progressively decomposed.
Database models (flat file vs relational)MediumCompare flat files with RDBMS. Highlight advantages of relational model.
Views of the database (external, conceptual, internal)MediumThree-schema architecture with diagram. Explain data independence.
SQL queries for GISMediumBasic SELECT, WHERE, AND/OR, JOIN operations. May include spatial SQL examples.
Databases and GIS integrationMediumHow attribute data is linked to spatial data. Geodatabases concept.
Data modeling / ER diagramsLowEntity, attribute, relationship concepts. Draw simple ER diagrams.

Part 1: Databases and Spatial DBMS Basics

Textbook Definitions (Textbook pp.158–170)

  • Database: “A large, computerized collection of structured data.” (Textbook p.158)
  • DBMS: “A software package that allows the user to set up, use and maintain a database.” (Textbook p.158)
  • Data Model: “A language that allows the definition of: the structures to store base data, integrity constraints, and computer programs to manipulate data.” (Textbook p.164)
  • Relation (Table): “A collection of tuples (records) that are similarly shaped.” (Textbook p.166)
  • Attribute: “A named field of a tuple, with which each tuple associates a value.” (Textbook p.166)
  • Key: “One or more attributes whose value uniquely identifies a tuple.” (Textbook p.169)
  • Query: “A computer program that extracts data from the database that meet the conditions indicated.” (Textbook p.161)
  • Declarative Language: The user defines what data to extract, not how. The DBMS determines the most efficient way to retrieve it. SQL is a declarative language. (Textbook p.161)

1. What is a Database and a Spatial DBMS?

PAST EXAM QUESTIONS ON THIS TOPIC:

  1. What is a database? What are the reasons for using a database management system? List out the four major types of database models used in GIS [1+3+2] (2071 Magh, Q3a)
  2. What is a spatial DBMS? Explain different types of DBMS structures [2+3] (2073 Magh, Q5)
Map View P1 P2 P3 Well Station Geometry (coordinates) Attribute Table FID Land Use Area m² Owner P1 Forest 1200 Gov. P2 Farmland 800 Ram P3 Wetland 600 Sita Non-spatial attributes Spatial DBMS Engine PostGIS · SDE · SpatiaLite Linked by Feature ID
Fig 5.1 – Spatial DBMS: How Map Features are Linked to Their Attribute Data

Reasons for Using a DBMS (Textbook pp.160–162)

  1. Large data volumes: Efficient storage and manipulation of datasets too large for manual handling.
  2. Data integrity: Integrity constraints prevent incorrect data from entering the database (e.g., age cannot be negative).
  3. Concurrent access: Multiple users can operate on the same database simultaneously with different views, without data conflicts.
  4. Declarative queries: Users specify what they want, not how to retrieve it, making data retrieval accessible to non-programmers.
  5. Data model support: Structured frameworks for organizing data logically.
  6. Backup and recovery: Protection against data loss from hardware failure or user error.
  7. Controlled redundancy: Minimizes data duplication while maintaining necessary copies for performance.

2. Reasons for using a Database Management System (DBMS)

PAST EXAM QUESTIONS ON THIS TOPIC:

  1. What is a database? What are the reasons for using a database management system? List out the four major types of database models used in GIS [1+3+2] (2071 Magh, Q3a)

Instead of keeping a bunch of messy Excel spreadsheets (Flat Files), engineers use a DBMS for several critical reasons:

  1. Reduces Data Redundancy: Data is stored in one central location, preventing multiple conflicting copies of the same file.
  2. Maintains Data Integrity: Enforces strict rules (e.g., you cannot enter text into a column meant for numeric Pipe Diameters).
  3. Data Security: Allows administrators to restrict who can view or edit specific data layers.
  4. Concurrent Access: Multiple engineers can view and edit the database simultaneously without crashing the file.

5 Components of a Database System (Lectures p.22)

  1. Hardware: The computer system on which the GIS/DBMS operates (servers, desktops, networked configurations).
  2. Software: The DBMS software that controls and manages the overall database, handling all user requests for data access.
  3. Data: All items stored in the database, organized in rows and columns within tables. Data can be arranged hierarchically, in navigation format, or relationally.
  4. Procedures: The steps to define needs, create a shortlist, evaluate options, implement software, and maintain the database.
  5. Database Access Language: Languages like SQL that include Data Definition Language (DDL) for creating database structures and Data Manipulation Language (DML) for accessing/modifying data.
Database System 1. Hardware Servers, computers, network infrastructure 2. Software DBMS (PostgreSQL, Oracle, PostGIS) 3. Data Tables, rows, columns (spatial + attribute) 4. Procedures Design, implement, maintain database 5. Access Language SQL (DDL + DML) queries & management
Fig 5.9 – Five Components of a Database System

Flat Files

No direct past exam questions have been asked from this section, but it is part of the syllabus and may appear in future exams.

A flat file is the simplest form of database — a single table stored as a plain text file (CSV, TXT) or spreadsheet (XLS) where all data is contained in one file with rows and columns. There are no relationships between tables, no indexing, and no query language.

Structure of a Flat File

Each row represents one record and each column represents one field/attribute. For example:

Building_IDNameTypeLatitudeLongitudeFloors
1City HallGovernment27.717285.32405
2KMC HospitalHospital27.693285.32148
3Durbar SchoolEducation27.704185.30653
.CSV buildings .csv Single Flat Table: buildings.csv ID Name Type Lat Lon Floors 1 City Hall Govt 27.717 85.324 5 2 Hospital Health 27.693 85.321 8 3 School Edu 27.704 85.306 3 Limitations of Flat Files: No Relationships Cannot link tables Redundancy Data repeated No SQL Support Manual filtering
Fig 5.10 – Flat File Structure: A Single Table with No Relationships or Query Language

Flat Files vs. DBMS

AspectFlat FileDBMS
StructureSingle tableMultiple related tables
Data redundancyHigh — same data repeated in many rowsLow — data normalized across tables
Data integrityNo enforcementEnforced through constraints and keys
Concurrent accessNot supported (file locking)Multiple users simultaneously
Query capabilityManual search or simple filtersSQL queries, spatial queries
ScalabilityPoor — slows with large dataHandles millions of records efficiently
Example.csv, .txt, .xls filesPostgreSQL/PostGIS, Oracle Spatial, MS SQL

Why GIS Moved Beyond Flat Files: Early GIS systems stored attribute data in flat files (e.g., .dbf files accompanying shapefiles). However, as datasets grew and projects required multi-user access, complex queries, and data integrity, GIS adopted relational database management systems (RDBMS). Flat files are still used for simple data exchange (e.g., CSV export from GPS receivers).

Part 2: The Four Major Database Models

PAST EXAM QUESTIONS ON THIS TOPIC:

  1. Explain different types of database management system [3] (2071 Bhadra, Q4a)
  2. Explain different types of database management systems [4] (2075 Magh, Q4a)
  3. Write short notes on: Different types of database management system [2] (2074 Bhadra, Q6i)
  4. What is a spatial DBMS? Explain different types of DBMS structures [2+3] (2073 Magh, Q5)
  5. What is a database? What are the reasons for using a database management system? List out the four major types of database models used in GIS [1+3+2] (2071 Magh, Q3a)
  6. Explain hierarchical database and relational database model with figure [6] (2072 Magh, Q5)

When asked to explain the different types of DBMS structures, you must list these four.

Hierarchical P C1 C2 Tree structure 1-to-Many (1:M) Parent → Children Network A B C D E Web / Graph Many-to-Many (M:N) Cross-linked nodes Relational ID | Name | Type 101 | Ram | Forest 102 | Sita | Farm FID | Desc | Area 101 | Parcel A | 500 102 | Parcel B | 800 PK=FK Tables + Keys JOIN on PK / FK GIS Standard Object-Oriented Building height, area, floors draw(), calcArea() Encapsulation Data + Methods OOP bundled object Self-contained
Fig 5.2 – The Four Major Database Models (Relational is the GIS standard)

Data Model Details (Lectures pp.22–24)

  • Hierarchical Model: Tree structure where each “parent” record has one-to-many “children” through pointers. Access is limited to the master/parent record. A child can only have one parent. (Cho, 1995)
  • Network Model: Solves the hierarchical model’s limitation by allowing many-to-many relationships. A “set” consists of an owner and a member record type. An owner can be a member in another set.
  • Relational Model: Most GIS use this. Key properties: values are atomic, each row is unique, column values are of the same kind, each column has a unique name, sequence of rows/columns is insignificant. Certain fields are designated as keys for indexing.
  • Object-Oriented Model: Based on real-world entities represented as objects with attributes (characteristics) and methods (behaviour). Classes group similar objects. Inheritance allows deriving new classes from existing ones.

1. Hierarchical Database Model

Hierarchical Database Model (Tree Structure) Nepal Province 1 Bagmati Morang Jhapa Kathmandu Lalitpur Ward 1 Ward 2 Each child → only ONE parent (1:M)
Fig 5.11 – Hierarchical Database Model: Tree Structure with One-to-Many Parent-Child Links

2. Network Database Model

Network Database Model (Graph / Web Structure) GIS Course Student A Student B Student C Survey Course CAD Course Children can have MULTIPLE parents (M:N)
Fig 5.12 – Network Database Model: Many-to-Many Relationships Forming a Web

3. Relational Database Model (RDBMS)

4. Object-Oriented Database Model

Object-Oriented Database: Class Inheritance in GIS SpatialFeature (Base Class) Attributes: geometry, srs, area Methods: draw(), buffer(), intersect() Building (Polygon) Attr: floors, type, owner Method: calculateTax() Road (Line) Attr: width, surface, lanes Method: calculateLength() WaterTap (Point) Attr: capacity, status Method: checkFlow() inherits Key OO Concepts Objects = Data + Methods | Inheritance = Reuse parent properties | Encapsulation = Hide internals
Fig 5.13 – Object-Oriented Database Model: Class Inheritance for GIS Spatial Features

Part 3: RDBMS in GIS and Maintaining Relationships

PAST EXAM QUESTIONS ON THIS TOPIC:

  1. Explain Rational data base system used in GIS [6] (2072 Ashwin, Q2b)
  2. Explain: Relational Database Management System [4] (2074 Magh, Q4a)
  3. Describe about RDBMS? Why is it used by GIS instead of other DBMS? [3] (2076 Bhadra, Q5a)
  4. Why GIS uses relational database management system? [3] (2079 Chaitra, Q5a)
  5. Explain RDBMS. How is the RDBMS used in GIS? [3] (2078 Chaitra, Q5a)
  6. Explain about relational database management system [3] (2073 Bhadra, Q5a)
  7. How relationships maintain in Relational Database Management System? [3] (2071 Bhadra, Q4b)
  8. How the relationship is maintained? [3] (2073 Bhadra, Q5b)
  9. How relationship maintains in relational database management system? (2075 Magh, Q4b)

This is the most heavily tested concept in the chapter.

Relational Model Key Concepts (Textbook pp.164–170)

  • Relation Schema: The definition of a relation’s name, its attributes, and their domains. Schemas are stable (change rarely). Relation instances (actual data rows) change frequently.
  • Attribute Domain: The set of atomic values an attribute can take (integer, real, string, date, etc.). “Atomic” means the smallest meaningful unit.
  • SDI (Spatial Data Infrastructure): “The relevant base collection of technologies, policies and institutional arrangements that facilitate the availability of and access to spatial data.” (Textbook p.146)

1. What is an RDBMS and How is it Used in GIS?

PAST EXAM QUESTIONS ON THIS TOPIC:

  1. Explain Relational database system used in GIS [6] (2072 Ashwin, Q2b)

A Relational Database Management System (RDBMS) organizes spatial and non-spatial data into tables (called relations).

2. How are Relationships Maintained in an RDBMS? (3 Marks)

PAST EXAM QUESTIONS ON THIS TOPIC:

  1. How relationships maintain in Relational Database Management System? [3] (2071 Bhadra Q4b)
  2. How the relationship is maintained? [3] (2073 Bhadra Q5b)
  3. How relationship maintains in relational database management system? [3] (2075 Magh Q4b)

Relationships between separate tables are established and maintained using mathematical keys strictly avoiding hard-coded links.

Table A: Land Parcels PK Parcel_ID Owner Area 101 Ram 500m² 102 Sita 800m² Table B: Tax Records FK FK_Parcel Tax_Amt Year 101 5000 2025 102 8000 2025 Primary Key = Foreign Key Parcel_ID (PK) ↔ FK_Parcel (FK) Matching values JOIN rows across tables
Fig 5.3 – How Primary Keys and Foreign Keys Maintain Relationships Between Tables
One-to-One Citizen Passport 1 has Each citizen has exactly one passport & vice versa 1 1 One-to-Many Province Dist. 1 Dist. 2 … 1 M One province contains many districts Many-to-Many Student A Student B GIS Survey M N Many students enroll in many courses & vice versa
Fig 5.4 – Three Types of Table Relationships: One-to-One One-to-Many and Many-to-Many

3. Why does GIS use RDBMS instead of other database systems? (3 Marks)

PAST EXAM QUESTIONS ON THIS TOPIC:

  1. Describe about RDBMS? Why is it used by GIS instead of other DBMS? [3] (2076 Bhadra Q5a)
  2. Why GIS uses relational database management system? [3] (2079 Chaitra Q5a)
  1. Flexibility: Unlike the rigid hierarchical model RDBMS allows you to join any table to any other table dynamically as long as they share a common key.
  2. Simplicity: Tables (rows and columns) are extremely intuitive for humans to read and understand.
  3. SQL Support: RDBMS uses Structured Query Language (SQL) standardizing how data is queried and edited across almost all software platforms (ArcGIS QGIS PostGIS).

Part 4: The SQL Join Scenario (10 Marks)

How can you join two different tables having one common attribute using a SQL assuming the following tables with common attribute landuse id in Table-1 and id in Table-2?

Table-1: Vector data of landuse polygons with columns fid landuse_id both being integer.
Table-2: Non-spatial table describing the land use with columns id and landuse_type (such as built-up farmland etc.). (2082 Shrawan)

This question tests if you can actually write the SQL code to perform the theoretical join we just discussed.

The Problem Setup:

How to join them: You join the two tables by matching the common attribute: landuse_id from Table-1 must equal id from Table-2.

The SQL Query Answer:

Write this exact SQL statement on your exam paper:

* join_query.sql
1
2
3
4
5
6
7
8
9
SELECT
Table_1.fid
Table_2.landuse_type
FROM
Table_1
INNER JOIN
Table_2
ON
Table_1.landuse_id = Table_2.id;
SQLUTF-8 · LF · 9 lines

Explanation for the Examiner:

Table 1: Landuse Polygons fid landuse_id 1 10 2 20 3 10 4 30 Table 2: Landuse Description id landuse_type 10 Built-up 20 Farmland 30 Forest INNER JOIN ON Table1.landuse_id = Table2.id Result: Joined Data fid landuse_id id landuse_type 1 10 10 Built-up 2 20 20 Farmland 3 10 10 Built-up 4 30 30 Forest Matching rows are combined; non-matching rows are excluded from INNER JOIN landuse_id = id Rows linked successfully
Fig 5.5 – SQL INNER JOIN: How Two Tables are Combined Using a Common Key

Data Modeling

No direct past exam questions have been asked from this section, but it is part of the syllabus and may appear in future exams.

Data modeling is the process of defining how real-world geographic features and their relationships will be organized, structured, and stored in a GIS database. It bridges the gap between the real world and the digital database.

Levels of Data Modeling

  1. Conceptual Model: A high-level, non-technical description of what data is needed. Uses Entity-Relationship (ER) diagrams.
    • Entities: The real-world objects to be represented (e.g., Road, Building, River, Parcel)
    • Attributes: Properties of each entity (e.g., Road has name, width, surface type)
    • Relationships: How entities relate to each other (e.g., a Building "is located on" a Parcel, a Road "crosses" a River)
  2. Logical Model: Translates the conceptual model into a database structure — defining tables, columns, data types, primary keys, and foreign keys. This is where normalization rules are applied.
  3. Physical Model: The actual implementation in a specific database system (e.g., PostGIS table creation SQL, ArcGIS geodatabase feature classes). Includes decisions about indexing, storage, and performance optimization.

Example: Simple GIS Data Model for a Municipality

EntityGeometry TypeKey Attributes
BuildingPolygonbuilding_id, type, floors, area_sqm, ward_no
RoadLineroad_id, name, width_m, surface_type
Ward BoundaryPolygonward_id, ward_name, population
Water Supply PointPointws_id, type, capacity_lps, status

Key Principle: Good data modeling ensures that the database can efficiently answer the spatial questions the project demands. A poorly modeled database leads to data redundancy, slow queries, and analytical errors.

Three Levels of Data Modeling Conceptual Model "WHAT data?" Road Bridge ER Diagram Non-technical Logical Model "HOW structured?" Roads Table road_id PK name Tables, PKs, FKs Normalization Physical Model "WHERE stored?" CREATE TABLE roads (...) PostGIS, indexing High Abstraction Low Real World Roads, buildings, rivers modeled progressively into database GIS Database PostGIS / ArcGIS GDB
Fig 5.14 – Three Levels of Data Modeling: Conceptual → Logical → Physical

Views of the Database

No direct past exam questions have been asked from this section, but it is part of the syllabus and may appear in future exams.

A database can be viewed at three different levels of abstraction, known as the Three-Schema Architecture (ANSI/SPARC model). This architecture ensures data independence — changes at one level do not affect the others.

The Three Schemas

  1. External Schema (View Level): What individual users or applications see. Different users can have different views of the same data. For example, a drainage engineer sees only pipe networks and catchment boundaries, while a land-use planner sees parcels and zoning layers — both accessing the same underlying database.
  2. Conceptual Schema (Logical Level): The community view of the entire database. It describes what data is stored and the relationships between entities, without specifying how the data is physically stored. This is the level defined by the data model (ER diagrams, table structures).
  3. Internal Schema (Physical Level): How the data is physically stored on disk — file structures, indexing methods, storage allocation, and access paths. This is managed by the DBMS and is invisible to end users.

Data Independence

Three-Schema Architecture (ANSI/SPARC) External View 1 Drainage Engineer Pipes, manholes External View 2 Land-Use Planner Parcels, zoning External View 3 Tax Officer Ownership, values View Level Logical Independence Conceptual Schema (Logical Level) Complete logical structure of the database ER diagrams, tables, relationships, constraints Logical Level Physical Independence Internal Schema (Physical Level) How data is stored on disk File structures, indexes, storage, access paths Physical Level
Fig 5.15 – Three-Schema Architecture: Data Independence Between View, Logical, and Physical Levels

Why This Matters in GIS: In a large municipal GIS, hundreds of users (engineers, planners, tax officers) access the same spatial database. The three-schema architecture ensures each user gets a customized view without interfering with others, and the database administrator can optimize physical storage without disrupting any user's workflow.

Database Views in Detail (Lectures p.24)

A database view is a subset of a database based on a query that runs on one or more tables. Views are saved as named queries and can be reused.

Types of Views:

  • Dynamic views: Contain data from one or two tables and automatically include all columns. Updated dynamically when related objects change.
  • Static views: Contain data from several tables with specific columns specified in SELECT and WHERE clauses. Updated manually.

Why Views are Important:

  1. Focus users on relevant data, hiding unnecessary information.
  2. Define frequently used joins/projections/selections so users don’t repeat conditions.
  3. Display different data for different users, even when sharing the same database.

Database Normalization

PAST EXAM QUESTIONS ON THIS TOPIC:

  1. What is data Normalization? Explain about 1NF and 2NF [3] (2076 Bhadra Q5b)
  2. What is data normalization? Explain 1NF and 2NF [4] (2078 Chaitra, Q5b)

1. What is Data Normalization?

Data Normalization is a systematic process of organizing data within a relational database to minimize redundancy (unnecessary duplication of data) and ensure data integrity (accuracy and consistency). It involves breaking down large clunky tables into smaller well-structured tables and defining relationships between them using primary and foreign keys.

By normalizing a database a GIS engineer ensures that updating a property owner's name only requires changing it in one single place rather than updating hundreds of separate parcel records.

2. Explain 1NF and 2NF (with rules)

Normalization is done in stages called "Normal Forms."

BEFORE (Violates 1NF) Emp_ID Name Phone_Numbers 101 Ram 9841234, 9801234 102 Sita 9812345, 9842345, 9862345 [X] Multiple values in one cell! Not atomic → Violates 1NF Fix AFTER (Satisfies 1NF) Emp_ID Name Phone 101 Ram 9841234 101 Ram 9801234 102 Sita 9812345 102 Sita 9842345 102 Sita 9862345 [OK] Each cell has ONE atomic value Rule: No multi-valued columns Rule: Each column has unique name Rule: Order of rows doesn’t matter
Fig 5.6 – First Normal Form (1NF): Eliminating Multi-Valued Cells
BEFORE (Violates 2NF — Partial Dependency) Project_ID (PK) Engineer_ID (PK) Engineer_Name Hours Project_Name P1 E1 Hari 40 Survey P1 E2 Gita 35 Survey Partial: Name depends only on Engineer_ID [X] Redundant! Split into 2NF Project_Assignments Table Project_ID (PK) Engineer_ID (PK) Hours P1 E1 40 P1 E2 35 [OK] Full dependency on composite key Engineers Table Engineer_ID (PK) Engineer_Name E1 Hari E2 Gita [OK] Name depends fully on Engineer_ID
Fig 5.7 – Second Normal Form (2NF): Removing Partial Dependencies from Composite Keys
Normalization Progression: Unnormalized → 1NF → 2NF → 3NF Unnormalized [X] Multi-valued cells Repeating groups 1NF Atomic values Each cell = single indivisible value 2NF Full dependency No partial deps on composite key 3NF No transitive deps Non-key depends only on PK 3NF Violation Example: Engineer_ID → Dept_ID → Dept_Name Dept_Name depends on Dept_ID, NOT directly on Engineer_ID (PK) = Transitive dependency [X] 3NF Fix: Table 1: Engineers (ID, Name, Dept_ID) Table 2: Departments (Dept_ID, Dept_Name) Each non-key → depends only on PK [OK]
Fig 5.16 – Database Normalization Progression: From Unnormalized to Third Normal Form (3NF)

Database Analysis (SQL and Keys)

PAST EXAM QUESTIONS ON THIS TOPIC:

  1. What is Structured Query Language (SQL)? Give an example to select few rows of a database table based on a condition [3] (2080 Chaitra, Q9a)
  2. What is the function of primary key in a table of a database? [3] (2080 Chaitra, Q9b)
  3. What is meant by querying a database? How can you use SQL to select all rural municipalities with population greater than a given value? (2081 Chaitra)
  4. What is meant by querying a database? How can you use SQL to select all rural municipalities with population greater than a given value? (2081 Chaitra)

1. What is SQL? Give an example.

PAST EXAM QUESTIONS ON THIS TOPIC:

  1. What is Structured Query Language (SQL)? Give an example to select few rows of a database table based on a condition [3] (2080 Chaitra, Q9a)
* select_parcels.sql
1
2
3
SELECT Parcel_ID, Owner_Name, Area
FROM Land_Parcels
WHERE Area > 500;
SQLUTF-8 · LF · 3 lines

2. What is the function of a Primary Key in a database table?

PAST EXAM QUESTIONS ON THIS TOPIC:

  1. What is the function of primary key in a table of a database? [3] (2080 Chaitra, Q9b)

The primary key is the absolute most important column in any GIS attribute table (often automatically generated as FID or OBJECTID). You should list these specific functions for full marks:

  1. Guarantees Uniqueness: It ensures that no two rows in a table are exactly identical. Even if two landowners have the exact same name and address, their unique Primary Key (e.g., Citizen_ID) separates them.
  2. Prevents Null Values: A primary key column strictly cannot be empty (NULL). Every single spatial feature must have an identifier.
  3. Anchors Relationships: It serves as the mathematical anchor point to link to other tables. When another table wants to reference this record, it uses the Primary Key as a "Foreign Key," allowing the RDBMS to instantly join the tables together.
  4. Optimizes Searching: Databases automatically "index" primary keys, making spatial queries and data retrieval extremely fast, even with millions of geographic records.
Four Functions of a Primary Key PK Primary Key 1. Uniqueness No duplicate rows Every record is unique 2. No NULL Cannot be empty Every feature has ID 3. Anchor Links FK references this PK Joins tables together 4. Fast Search Auto-indexed by DBMS Instant retrieval
Fig 5.17 – Four Critical Functions of a Primary Key in GIS Databases

Querying a Database

1. What is meant by querying a database?

Definition: Querying a database means submitting a specific, logically structured request to the Database Management System (DBMS) to retrieve a subset of data that matches certain defined conditions.

In the context of GIS: A query acts as a strict mathematical filter. Instead of scrolling through an attribute table with 753 local level boundaries looking for specific ones, a query automatically searches the database and isolates only the spatial features (polygons) and tabular records that meet your exact engineering or demographic criteria, completely ignoring the rest. Crucially, a query only views or selects the data; it does not permanently delete or alter the original database.

FROM Select the source table WHERE Apply filter conditions SELECT Pick which columns to show RESULT SET Filtered rows with selected columns only Example: SELECT id, name FROM Parcels WHERE area > 500; Parcels (all 10,000 rows) area > 500 (filters to 243 rows) id, name (2 of 8 columns) 243 rows × 2 cols (precise subset) SQL processes: FROM → WHERE → SELECT (this is the logical execution order)
Fig 5.8 – SQL Query Execution Flow: How a Database Processes Your Query

2. SQL Example: Select Rural Municipalities by Population

How can you use a SQL to select all the rural municipalities having population between 10000 and 30000, provided that you have a polygon vector data of municipalities with columns: id, name, type-of-municipality (gaunpalika: rural municipality, nagarpalika, upmahanagarpalika, mahanagarpalika) and population?

The Problem Setup:

The SQL Query Answer:

To secure full marks, write this exact SQL statement on your exam paper. (Note: When column names contain hyphens like type-of-municipality, they are usually wrapped in quotes or brackets in SQL to prevent math errors, but writing it standardly is accepted in theory exams).

* rural_municipalities.sql
1
2
3
4
5
SELECT id, name, population
FROM Municipalities
WHERE type-of-municipality = 'gaunpalika'
AND population >= 10000
AND population <= 30000;
SQLUTF-8 · LF · 5 lines

(Alternative valid syntax for the population line: AND population BETWEEN 10000 AND 30000;)

GIS–Database Integration Architecture Spatial Data Geometry Point Line Polygon Attribute Data RDBMS Tables ID Name SQL queries LINK Feature ID = PK/FK Spatial Join GIS Software (ArcGIS / QGIS / PostGIS) Spatial query + Attribute query = Powerful analysis Maps + Reports + Analysis
Fig 5.18 – GIS–Database Integration: Linking Spatial Geometry with Attribute Tables

Explanation for the Examiner:

To guarantee maximum marks, briefly explain what your code does below the query:

Chapter Summary

This chapter covers database concepts essential for GIS. It begins with database fundamentals: what a database is, its components (tables, records, fields), and the role of a Database Management System (DBMS). Flat file systems and their limitations (data redundancy, inconsistency, lack of integrity) are discussed. The relational database model (RDBMS) is the core focus — data organized in tables (relations) linked through primary keys and foreign keys. Data modeling using Entity-Relationship (ER) diagrams helps design the logical structure before implementation. Three views of the database are explained: external (user view), conceptual (logical structure), and internal (physical storage). Normalization (1NF, 2NF, 3NF) eliminates redundancy and ensures data integrity. SQL basics for querying spatial databases (SELECT, WHERE, JOIN) are introduced. The chapter concludes with how databases integrate with GIS — linking non-spatial attribute tables with spatial geometry for powerful analysis.