Presentation on theme: "Introduction to Spatial Databases Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Advanced Database Applications Kocaeli University Spring."— Presentation transcript:
Introduction to Spatial Databases Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Advanced Database Applications Kocaeli University Spring 2013
What is a SDBMS ? A SDBMS is a software module that can work with an underlying DBMS supports spatial data models, spatial abstract data types (ADTs) and a query language from which these ADTs are callable supports spatial indexing, efficient algorithms for processing spatial operations, and domain specific rules for query optimization
Why Spatial Databases GIS is the principle technology motivating interest in SDBMS. GIS is not the only area using SDBMS Many important application domains have spatial data and queries. Some Examples Insurance Risk Manager: Which homes are most likely to be affected in the next great flood on the Brisbane river? Molecular Biologist: Is the topology of the amino acid biosynthesis gene in the genome found in any other sequence feature map in the database ? Medical Doctor: Based on this patient's MRI, have we treated somebody with a similar condition ?
What is a Spatial Database? A spatial database is a database system (DBMS) that is optimized to store and query basic spatial objects : Point: a house, a moving car, a city Line/Polyline: river, cable, road Polygon: a county, forest, lake, city And some more – see the nest slide
Spatial Object Types in OGIS Data Model Each rectangle shows a distinct spatial object type 2-dim geometry Collection of islands Collection of oil wells
Spatial Data Examples Examples of non-spatial data Names, phone numbers, addresses of people Examples of Spatial data NASA satellites imagery - terabytes of data per day Weather and Climate Data Rivers, Farms, ecological impact Medical Imaging Exercise: Identify spatial and non-spatial data items in A phone book A cookbook with recipes
Spatial and Non-Spatial Queries Non-spatial queries: List the names of all bookstore with more than ten thousand titles. List the names of ten customers, in terms of sales, in the year 2001 Where is Building 78? Which courses are meeting in GP Building? Spatial Queries: List the names of all bookstores with ten miles of Minneapolis List all customers who live in Tennessee and its adjoining states Which buildings are adjacent to the lake? Which building is adjacent to a lake?
Spatial Query Example -1 Spatial query language Spatial data types, e.g. point, linestring, polygon, … Spatial operations, e.g. overlap, distance, nearest neighbor, … Callable from a query language (e.g. SQL3) of underlying DBMS SELECTS.name FROMSenator S WHERE S.district.Area() > 300 Standards SQL3 (a.k.a. SQL 1999) is a standard for query languages OGC is a standard for spatial data types and operators Both standards enjoy wide support in industry
Spatial Query Example -2 Display all countries that border Turkiye. This query can be implemented using the following SQL command: select c1.name as name,transform(c1.the_geom,4326) as the_geom from county c1,county c2 Where touches(c1.the_geom,c2.the_geom) And c2.name=Turkiye';
Spatial Query Example -3 Query: For all the rivers listed in the River table, find the counties through which they pass. SELECT r.name, r.name FROM river AS r, county AS c WHERE crosses(r.the_geom,c.the_geom)=True The spatial predicate Cross is used to join River and Country tables To view this we would add asbinary( R.the_geom,C.the_geom)
A spatial join associate two tables based on a spatial relationship, rather than an attribute relationship. For example the query: Summarize the provincial election results by municipality. SELECT m.name, sum(v.ndp) AS ndp, sum(v.lib) AS liberal, sum(v.gp) AS green, sum(v.upbc) AS unity, sum(v.vtotal) AS total FROM bc_voting_areas v, bc_municipality m, WHERE intersects(v.the_geom, m.the_geom) GROUP BY m.name ORDER BY m.name; Spatial Query Example -4
Spatial Query Example -5 Spatial join example SELECT S.name FROM Senator S, Business B WHERE S.district.Area() > 300 AND Within(B.location, S.district) Non-Spatial Join example SELECT S.nameFROM Senator S, Business B WHERE S.soc-sec = B.soc-sec AND S.gender = Female
SDBMS vs GIS ? GIS is a software to visualize and analyze spatial data using spatial analysis functions such as Search Thematic search, search by region, (re-)classification Location analysis Buffer, corridor, overlay Terrain analysis Slope/aspect, catchment, drainage network Flow analysis Connectivity, shortest path Distribution Change detection, proximity, nearest neighbor Spatial analysis/Statistics Pattern, centrality, autocorrelation, indices of similarity, topology: hole description Measurements Distance, perimeter, shape, adjacency, direction GIS uses SDBMS to store, search, query, share large spatial data sets
SDBMS vs GIS ? SDBMS focuses on Efficient storage, querying, sharing of large spatial datasets Provides simpler set based query operations Example operations: search by region, overlay, nearest neighbor, distance, adjacency, perimeter etc. Uses spatial indices and query optimization to speedup queries over large spatial datasets. SDBMS may be used by applications other than GIS Astronomy, Genomics, Multimedia information systems, …
Components of a SDBMS Recall: a SDBMS is a software module that can work with an underlying DBMS supports spatial data models, spatial ADTs and a query language from which these ADTs are callable supports spatial indexing, algorithms for processing spatial operations, and domain specific rules for query optimization Components include spatial data model, query language, query processing, file organization and indices, query optimization, etc.
Three Layer Architecture
SDBMS Example Consider a spatial dataset with: County boundary (dashed white line) Census block - name, area, population, boundary (dark line) Water bodies (dark polygons) Satellite Imagery (gray scale pixels) Storage in a SDBMS table: create table census_blocks ( name string, area float, population number, boundarypolyline);
Modeling Spatial Data in Traditional DBMS A row in the table census_blocks Question: Is Polyline datatype supported in DBMS?
Mapping census_table into a Relational Database