GIS and the Relational Model
Transcript of GIS and the Relational Model
-
8/9/2019 GIS and the Relational Model
1/35
Attribute Data and RelationalDatabase
Lecture 59/21/2006
-
8/9/2019 GIS and the Relational Model
2/35
definitionAttribute data is about what of a spatial
data and is a list or table of data arrangedas rows and columnsRows are records (map features)
Each row represents a map feature, which has aunique label ID or object ID
Columns are fields (characteristics)
Intersection of a column and a row shows thevalues of attributes, such as color, ownership,magnitude, classification,
-
8/9/2019 GIS and the Relational Model
3/35
Data types of attribute data: character, integer, floating, dateEach field must be defined with a data type, data width, number ofdecimal places
The width refers to the number of space reserved for a field
-
8/9/2019 GIS and the Relational Model
4/35
-
8/9/2019 GIS and the Relational Model
5/35
-
8/9/2019 GIS and the Relational Model
6/35
A database neededIf many fields related to one record (feature-ID),for example, the a soil unit can have over 80estimated physical and chemical properties, moretables are needed to store all the attributes.A database management system (DBMS) isneeded to manage multiple tables.A database is a collection of interrelated tables indigital format. There are four types:
Flat file, hierarchical database, network database,relational database
In GIS, we usually use relational database
-
8/9/2019 GIS and the Relational Model
7/35
HierarchicalFlat file
RelationalNetwork
PIN: Parcel ID number
Zoning (zonecode): 1-residential, 2-commercial Chang, 2004
-
8/9/2019 GIS and the Relational Model
8/35
Relational databaseA relational database is a collection of tables, also called
relations, which can be connected to each other by keys.A primary key represents one or more attributes whosevalues can uniquely identify a record in a table. Its counterpartin another table for the purpose of linkage is called a foreignkey
AdvantagesEach table in the database can be prepared, maintained, andedited separately from other tablesEfficient data management and processing, since linking tablesquery and/or analysis is often temporary
NormalizationIs steps (processes) to separate a large attribute table intosmall relational tablesTo reduce data redundancy, remove multiple values in onecells in a table, andTo make efficient data storage and management possible
-
8/9/2019 GIS and the Relational Model
9/35
Normalization rulesRule 1: Fields should be Atomic; that is each piece of data should bebroken down as much as possible. For example, rather thancreating a field called NAME, you would create two fields : one forthe first name and the other for the last name.
Rules 2 and 3: Each record should contain a unique identifier so thatyou have a way of safely identifying the record. A Social SecurityNumber is ideal, because no two people have the same one. Theunique identifier is call a primary key. You may select one of thefields in the table as the primary key if that field would nevercontain duplicate values for the different records. An example of agood choice would be the social security number field. If none ofthe fields are suitable, the program can add a counter field that willautomatically assign a unique number to each record as it is entered
Rule 4: The primary key should be short, stable, and simple.Addresses and even last names may change several times during apersons life time. This is why governments and companies assign
permanent identification numbers.
-
8/9/2019 GIS and the Relational Model
10/35
Rule 5: Every other field in the record should supplyadditional information about the person or thing that isuniquely identified by the primary key. For example, a tablethat contains data about employees may include a field thatindicates the employees supervisors.
Rule 6: Information in the table should not appear in morethan one place. For example, if you tried to create a table ofthe different committees in an organization and had fieldswith name like Chairperson, Member1, Member2, andMember3, the same person could be the chair of onecommittee and Member1 in another. If that person changedhis name, you would have to change it in more than one
place. Avoid numbered field names like those shown in thisexample.
-
8/9/2019 GIS and the Relational Model
11/35
Normal(lization) formsFirst Normal Form
Eliminate repeating groups in individual tablesCreate a separate table for each set of related data.Identify each set of related data with a primary key.
Second Normal FormCreate separate tables for sets of values that apply tomultiple records
Relate these tables with a foreign key.Third Normal Form
Eliminate fields that do not depend on the key.
-
8/9/2019 GIS and the Relational Model
12/35
Example 1, Original TableStudent# Advisor Adv-Room Class1 Class2 Class3
1022 Jones 412 101-07 143-01 159-02
4123 Smith 216 201-01 211-02 214-01
From Microsoft Knowledge Base Article - 209534
-
8/9/2019 GIS and the Relational Model
13/35
First Normal Form TablesStudent# Advisor Adv-Room Class#
1022 Jones 412 101-07
1022 Jones 412 143-01
1022 Jones 412 159-02
4123 Smith 216 201-01
4123 Smith 216 211-02
4123 Smith 216 214-01
-
8/9/2019 GIS and the Relational Model
14/35
Second Normal FormEliminate Redundant DataRegistration:Students:
Student# Class#
1022 101-07
1022 143-01
1022 159-02
4123 211-01
4123 211-024123 214-01
Student# Advisor Adv-Room
1022 Jones 412
4123 Smith 216
-
8/9/2019 GIS and the Relational Model
15/35
Third Normal FormEliminate Data Not Dependant On KeyStudents: Registration:
Student# Class#
1022 101-07
1022 143-011022 159-02
4123 211-01
4123 211-02
4123 214-01
Student# Advisor
1022 Jones
4123 Smith
Faculty:
Name Room
Jones 412
Smith 216
-
8/9/2019 GIS and the Relational Model
16/35
Example 2: normalization
Multiple values in one cells, data redundancyFirst norm
Data redundancy Second norChang, 2004
-
8/9/2019 GIS and the Relational Model
17/35
Chang, 2004
Third norm
-
8/9/2019 GIS and the Relational Model
18/35
Separate tables after normalization
Chang, 2004
-
8/9/2019 GIS and the Relational Model
19/35
Relationship of those separate tablesOne record in one tablerelated to one record inanother table
One record in one tablerelated to many records in
another table
Many records in one tablerelated to one record inanother table
Many records in one tablerelated to many records inanother table
-
8/9/2019 GIS and the Relational Model
20/35
Join and relate tablesOnce tables are separatedas relational tables, thentwo operations can be usedto link those tables duringquery and analysis
Join, brings together twotables based on acommon key.Relate, connects two
tables (based on keys)but keeps the tablesseparate.
Keys do not have to have
the same name but must beof the same data type
Join
relate
Join
relate
-
8/9/2019 GIS and the Relational Model
21/35
One-to-One JoinEmployee-id Job
1 Digislave
2 Useless Supervisor
Employee-id name
1 Tom
2 John
Join Employee-id to Employee-id
After join
Employee-id Job Name
1 Digislave Tom
2 Useless Supervisor John
-
8/9/2019 GIS and the Relational Model
22/35
Many-to-One JoinSymbol Description
Qa Quaternary Alluvium
Qe Quaternary Eolian
Pa Permian Abo
Polygon Id Symbol
1 Qa
2 Qa
3 Pa
4 Qe
Polygon ID Symbol Description
1 Qa Quaternary Alluvium
2 Qa Quaternary Alluvium
3 Pa Permian Abo
4 Qe Quaternary Eolian
After Join on Symbol
-
8/9/2019 GIS and the Relational Model
23/35
One-to-Many RelatesSymbol Mineral
Qa Quartz
Pa Quartz
Qa Gypsum
Pa Feldspar
Formation Symbol
Quaternary Alluvium Qa
Permian Abo Pa
If the tables are related on Symbol, selectingPolygon-id 1 will select the highlighted areas.
-
8/9/2019 GIS and the Relational Model
24/35
Many-to-Many Relates
Formation Symbol
1 Qa
2 Qa
Symbol Mineral
Qa Quartz
Pa Quartz
Qa Gypsum
Pa Feldspar
If the tables are related on Symbol, selectingPolygon-id 1 will select the highlighted areas.
-
8/9/2019 GIS and the Relational Model
25/35
In ArcGIS GISThose separate tables will have one and only onetable called spatial table (or layer attribute table),which has spatial location and relationship with thespatial data. Other tables called nonspatial tables,which can be either join or relate to the spatialtable.Join tables when each record in the spatial tablehas no more than one matching record in thenonspatial table
One to one relationMany to one relation
Relate tables when each record in the spatial table
has more than one record in the nonspatial tableOne to many relationMany to many relation
-
8/9/2019 GIS and the Relational Model
26/35
-
8/9/2019 GIS and the Relational Model
27/35
The joined table
The joined table will only preserved within the mapdocument-the tables remain separate on disk-and can beremoved at any time
-
8/9/2019 GIS and the Relational Model
28/35
R l d bl
-
8/9/2019 GIS and the Relational Model
29/35
Related tables
The related table will only preserved within the map document-thetables remain separate on disk-and can be removed at any time
-
8/9/2019 GIS and the Relational Model
30/35
GeodatabaseBefore geodatabase, in one GIS project,
many GIS files (spatial data andnonspatial data) are stored separated. Sofor a large GIS project, the GIS files couldbe hundreds.Within a geodatabase, all GIS files (spatialdata and nonspatial data) in a project canbe stored in one geodatabase, using therelational database management system
(RDMS)
-
8/9/2019 GIS and the Relational Model
31/35
Types of geodatabases
personalenterprise
P l G d b
-
8/9/2019 GIS and the Relational Model
32/35
Personal Geodatabase
The personal geodatabase isgiven a name of filename.mdb
that is browsable and editableby the ArcGIS, and it can alsobe opened with MicrosoftAccess. It can be read bymultiple people at the sametime, but edited by only oneperson at a time. maximumsize is 2 GB.
-
8/9/2019 GIS and the Relational Model
33/35
Multiuser Geodatabase
Multiuser (ArcSDE or enterprise) geodatabaseare stored in IBM DB2, Informix, Oracle, orMicrosoft SQL Server.
It can be edited through ArcSDE by many usersat the same time, is suitable for largeworkgroups and enterprise GISimplementations. no limit of size. support rasterdata.
-
8/9/2019 GIS and the Relational Model
34/35
3-tier ArcSDE client/server architecture with boththe ArcSDE and Oracle RDBMS running on thesame server, which minimizes network trafficand client load while increasing the server load
compared to 2-tier system, in which the clientsdirectly connect to the RDBMS
Personal and Multiuser Geodatabase
-
8/9/2019 GIS and the Relational Model
35/35
Personal and Multiuser Geodatabase
Comparison
source: www.esri.com