Download presentation
Presentation is loading. Please wait.
Published byRalph Bradley Modified over 9 years ago
1
GIS Table Analysis
2
2121 Geographic Data Tabular Data Standard GISDataModel Linked spatial and attribute data ID AgeTypePavement 1124LnBitumen 222LnConcrete 3951LnDirt etc. IDLake SizeQuality 99 93.24 10065.73 12255.30 etc.
3
For each layer there is typically a one-to-one relationship between geographic features (point, line, or polygon) and records in a table
4
Terminology Database – an organized collection of data Table – data organized in rows and columns Attribute – a variable or item Record – a collection of attributes Domain – the range of values an attribute may take Index/key – attribute(s) used to identify, organize, or order records in a database
5
integer domain real domain alpha- numeric domain (a string) R e cord (o r tuple) Attribute (or item or field) Commoncomponentsofadatabase: IDAREAAREAPerimClassCode 2739.255.4a11z 14192.4192.477.3a119f
6
A DBMS provides Translation (many views on the data) Protection (e.g., against errors due to simultaneous updates)
7
Multi-tiered architecture Isolates end user (upper tier) from changes at lower tiers Allows integration of multiple divergent data sources
8
Common Database Models: Flat File Hierarchical Network Relational
9
Flat File Data in a “text” or other lightly formatted file. Little structure, cross- referencing or linking among entries. Often in a row/column format Advantages: Transparent, easily transportable Disadvantages: Little structure, few error safeguards
10
Relational Database Model Minimal row- column structure Items/records with specified domains (possible values) Advantages: Minimum structure, easy programming, flexible Disadvantages: Relatively slow, a few restrictions on attribute content
11
Relational Databases Are Most Common Flexible Relatively easy to create and maintain Computer speeds have overcome slow response in most applications Low training costs Inertia – many tools are available for RDBMS, large personnel pool
12
Hybrid Database Coordinate data as a connected structure Attribute data as a relational table
13
Eight Fundamental Operations Restrict (query) – subset by rows Project – subset by columns Product – all possible combinations Divide – inverse of product
14
Eight Fundamental Operations Union – combine top to bottom Intersect – row overlap Difference – row non-overlap Join (relate) – combine by a key column
15
Main OperationswithRelational Tables Query/Restrict Conditional selection Calculation and Assignment Sort rank based on attributes Relate/Join Temporarily combine two tables by an index
16
Query / Restrict Operations with Relational Tables Set Algebra Uses operations less than ( ), equal to (=), and not equal to (<>). Boolean Algebra uses the conditions OR, AND, and NOT to select features. Boolean expressions are evaluated by assigning an outcome, True or False, to each condition.
17
Query / Restrict Operations with Relational Tables Each record is inspected andis added to the selected set if it meets one to several conditions AND, OR and NOT may be applied alone or in combinations AND typically decreases the number of records selected ORtypically increases the number of records selected NOT Is the negation operation and is interpreted as meaning select those that do not meet the condition following the NOT.
18
Query / Restrict – simple, AND
19
Query / Restrict – OR, NOT
20
Operation Order is Important in Query (D OR E) AND Fmay not be the same asD OR (E AND F) NOT (A and B) may not be the same as [ NOT (A) AND NOT (B)] Typically need to clarify order with delimiters
21
NAME
28
StructuredQueryLanguage (SQL) A standard system for query syntax Uniformly interpreted set of operations, e.g., CREATE INSERT SELECT Anybody can (and it appear everybody has) create a database “engine” that fits under SQL – then we can switch vendors and upgrade whenever we want….in theory.
29
CREATETABLEinformix.culverts ( se_row_idserialprimarykey, shapeST_Point); CREATEINDEXculverts_ix2 ONculverts(shapeST_Geometry_Ops) USINGRTREE; INSERTINTOgeometry_columns VALUES( "hamlet", "informix", "culverts", "shape", NULL, 1, NULL, 0 ); --ThecodeforaPoint...... Source:http://spatial.informix.com/products/spatial/Examples/SQL/forestry/ww2e.htme:htt://spatial.informix.com/products/spatial/Examples/SQL/forestry/ww2e.htm SQL Example (Creating a file of points where roads and streams intersect)
30
Recap Query / Restrict Set Algebra Uses operations less than (<), greater than (>), equal to (=), and not equal to (<>). Boolean Algebra uses the conditions OR, AND, and NOT to select features.Boolean expressions are evaluated by assigning an outcome, True or False, to each condition. SQL - Structured Query Language
31
SELECT AREA > 8.0 1. 3. 2. 4. 5. COLOR = blue OR ID = F NOT (COLOR = blue)NOT (COLOR = blue) ID < cID < c COLOR = blue AND AREA > 10 OR ID = g Practice Do not turn in
32
SELECT AREA > 8.0 1. 3. 2. 4. 5. COLOR = blue OR ID = F NOT (COLOR = blue)NOT (COLOR = blue) ID < CID < C COLOR = blue AND AREA > 10 OR ID = g
37
OUTER JOIN
38
INNER JOIN
39
Main OperationswithRelational Tables Query / Selection Conditional selection Calculation and Assignment Sort rank based on attributes Relate/Join Temporarily combine two tables by an index
40
Calculation and Assignment Slope = “steep” Aspect = 45.2 Cost =[ M * U + cos (distance) ] / (F – P/R*T)
41
Main OperationswithRelational Tables Query/Selection Conditional selection Calculation and Assignment Sort rank based on attributes Relate/Join Temporarily combine two tables by an index
42
Sort – ordering by attribute values Simple sort – ascending AREA Compound sort – ascending Type, then descending AREA within Type NameNameAREAAREAclassclassTypeType Emily, Lake52,222.61Limnetic zone Emily, Lake58,662.21Limnetic zone 60,826.62Shallow lakes 64,588.52Shallow lakes 70,590.32Shallow lakes Long Lake88,259.51Limnetic zone 143,285.32Littoral zone Sleepy Eye Lake170,797.12Littoral zone Mud Lake193,318.52Shallow lakes Goldsmith Lake201,127.12Littoral zone Emily, Lake336,343.22Littoral zone 349,528.71Limnetic zone 384,160.12Littoral zone Emily, Lake420,798.41Limnetic zone Savidge Lake479,709.72Littoral zone Emily, Lake545,381.81Limnetic zone Dog Lake635,537.02Littoral zone Duck LakeDuck Lake1,126,331.91Limnetic zone Wita Lake1,354,583.22Littoral zone 1,418,133.31Limnetic zone Ballantyne Lake1,428,331.51Limnetic zone Washington, LakeWashington, Lake1,914,835.31Limnetic zone 1,937,698.61Limnetic zone 4,040,675.71Limnetic zone NameNameAREAAREAclassclassTypeType 4,040,675.71Limnetic zone 1,937,698.61Limnetic zone Washington, Lake1,914,835.31Limnetic zone Ballantyne Lake1,428,331.51Limnetic zone 1,418,133.31Limnetic zone Duck Lake1,126,331.91Limnetic zone Emily, Lake545,381.81Limnetic zone Emily, Lake420,798.41Limnetic zone 349,528.71Limnetic zone Long Lake88,259.51Limnetic zone Emily, Lake58,662.21Limnetic zone Emily, Lake52,222.61Limnetic zone Dog Lake635,537.02Littoral zone Wita Lake1,354,583.22Littoral zone Savidge Lake479,709.72Littoral zone 384,160.12Littoral zone Emily, Lake336,343.22Littoral zone Goldsmith Lake201,127.12Littoral zone Sleepy Eye Lake170,797.12Littoral zone 143,285.32Littoral zone Mud Lake193,318.52Shallow lakes 70,590.32Shallow lakes 64,588.52Shallow lakes 60,826.62Shallow lakes
43
Main OperationswithRelational Tables Query/Selection Conditional selection Calculation and Assignment Sort rank based on attributes Relate/Join Temporarily combine two tables by an index
44
Tables in GIS Attribute tables are often huge We have to maintain our tables (change values, remove, add records or items) Different people/applications are interested in different subsets of attributes (columns) We often break our tables up into pieces (many tables), and use relational joins as needed to combine them back together
45
A Relational Join
46
Relational Tables This is common because most users do not understand the concepts Normal Forms in relational tables. Relational tables have many advantages, but If improperly structured, they may suffer from: Poor performance Inconsistency Redundancy Difficult maintenance
47
Relational Tables This is common because most users do not understand the concepts Normal Forms in relational tables. Relational tables have many advantages, but If improperly structured, table may suffer from: Poor performance Inconsistency Redundancy Difficult maintenance
48
Tables in Non-normal Form repeat columns, “dependent” data, empty cells by design
49
Normal Forms AreGood Because: It reduces total data storage Changing values in the database is easier It “insulates” information – it is easier to retain important data Many operations are easier to code
50
1 st Normal Forms in Relational Tables Tables are in first normal form when there are no repeat columns Advantages: easy to code queries (can look in only one column) Disadvantages: slow searches, excess storage, cumbersome maintenance
51
2 nd Normal Forms in Relational Tables 2NF if: it is in 1NF and if every non-key attribute is functionally dependent on the primary key What is a key? An item or set of items that may be used to uniquely identify every row What is functional dependency? If you know an item (or items) for a row, then you automatically know a second set of items for the row – this means the second set of items is functionally dependent on the item (or items)
52
Keys Item(s) that uniquely identify a row STATE can be a key, but not REGION, SIZE, or POPULATION
53
Sometimes we need >1 column to form a key, e.g., Parcel-ID and Own-ID together may form a key Keys Item(s) that uniquely identify a row
54
Functional Dependency Knowing the value of an item (or items) means you know the values of other items in the row e.g., if we know the person’s name, then we know the address In our example, if we know the Parcel-ID, we know the Alderman, Township name, and other Township attributes: Parcel-ID - > AldermanParcel-ID - > Thall_add Parcel-ID - > Tship-ID Parcel-ID - > Tship_name
55
Moving from First Normal Form (1NF to Second Normal Form (2NF), we need to: Identify functional dependencies Place in separate tables, one key per table
56
3 rd Normal Forms in Relational Tables Remove transitive functional dependencies A transitive functional dependency is when A -> B (if we know A, then we know B) and B -> C (if we know B, then we know C) So A -> C (if we know A, then we know C). To be in 3NF, we must identify all transitive functional dependencies, and remove them, typically by splitting the table(s) that contain them
58
In our example, one transitive functional dependency: Parcel-ID -> Tship-ID, Alderman Tship-ID -> Tship_name, Thall_add
60
Bad Things in (unormalized) Relational Tables: Repeat (or similar) variables e.g., parcel #, owner 1, owner2, owner3, owner 4 Multiple dependencies per record e.g., owner name, house#, street, city, county, zipcode, state, country Repeat records Many blank cells
61
Normal Forms Summary No repeat columns (create new records such that there are multiple records per entry) Split the tables, so that all non-key attributes depend on a primary key. Split tables further, if there are transitive functional dependencies. This results in tables with a single, primary key per table.
62
Normal Forms AreGood Because: It reduces total data storage Changing values in the database is easier It “insulates” information – it is easier to retain important data Many operations are easier to code
64
In ArcGIS 10 Per capita energy use 40 million) and (car theft <1) The order of operations is assumed to be this When you don’t include parentheses Per capita energy use < 4,000 OR ( (population > 40 million) and (car theft <1) )
65
YOU MUST TURN IN THE ANSWERS TO THIS SHEET WITH YOUR LAB ASSIGNMENT
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.