Mastering ArcGIS Chapter 7 Queries.

Slides:



Advertisements
Similar presentations
Database Management Systems and Enterprise Software
Advertisements

Relational Algebra, Join and QBE Yong Choi School of Business CSUB, Bakersfield.
NSF DUE ; Chérie Aukland. NSF DUE ; GeoTEd Partners.
Data Storage and Processing GIS Topics and Applications.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Geodatabase basic. The geodatabase The geodatabase is a collection of geographic datasets of various types used in ArcGIS and managed in either a file.
2-1 Making Decisions Sample assignment statements PayAmount = Hours * Rate PayAmount = 40*Rate + (Hours – 40)*Rate*1.5.
Your name here The lecture notes are based on using Microsoft Access interactively as part of the lecture.
Mark Dixon Page 1 02 – Queries: Query by Example.
Computer Science & Engineering 2111 CSE 2111 Lecture Querying a Database 1CSE 2111 Lecture- Querying a Database.
GIS Data Models Components of a GIS Map Common Data Models.
CORE 2: Information systems and Databases STORAGE & RETRIEVAL 2 : SEARCHING, SELECTING & SORTING.
Attributes & Queries Reading Assignment: Bolstad, Ch. 8 (p )
GIS UPDATE? Lecture 17 Lab 8: Music Festival, Part 2 – Spatial Analysis.
GIS Concepts ‣ What is a table? What is a table? ‣ Queries on tables Queries on tables ‣ Joining and relating tables Joining and relating tables ‣ Summary.
Attribute Data in GIS Data in GIS are stored as features AND tabular info Tabular information can be associated with features OR Tabular data may NOT be.
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 4 BACKNEXTEND 4-1 LINKS TO OBJECTIVES Query Design Query Criteria Modify a Query Using OR.
CHAPTER 8: MANAGING DATA RESOURCES. File Organization Terms Field: group of characters that represent something Record: group of related fields File:
Introduction to ArcGIS for Environmental Scientists Module 2 – Fundamentals Chapter 7 – Queries.
WinGapSQL and GIS Mark Lovett & Rusty Scoven
Computer Science & Engineering 2111 Lecture 11 Querying a Database 1.
City of Chula Vista using query layers to map field work Bob Blackwelder City of Chula Vista.
Map Algebra. Lesson 5A overview  Introduction to Map Algebra (5A)  Language components  Syntax and rules  Objects  Operators  Commands  Exercise.
Lecture 2: Data Exploration Jianfei Chen School of Geographical Sciences GuangZhou University GunagZhou, China
Data Queries Selecting features in ArcMap Data queries  Important part of a GIS project Can be a part of your data preparation or final analysis  Data.
Computer Science & Engineering 2111 Querying a Database 1CSE 2111 Lecture- Querying a Database.
CHAPTER 4: Selection Control Structure. Objectives  Use the relational comparison operators  Learn about AND logic  Learn about OR logic  Make selections.
Copyright © 2006 by Maribeth H. Price 5-1 Chapter 5 Working with Tables.
Performing Calculations—1 of 2 In addition to using queries to retrieve, update, sort, and filter data in a database, you can use a query to perform calculations.
Queries Select by Attribute Select by Location. What is a Query? A query extracts information from a data table for further use –Once extracted you can:
Copyright © 2006 by Maribeth H. Price 6-1 Chapter 6 Queries.
Query and Reasoning. Types of Queries Most GIS queries will select spatial features Query by Attribute (Select by Attribute) –Structured Query Language.
Access Chapter 3-Obtaining Answers to Your Data Questions.
Queries Objective 5.02 Understand queries, forms, and reports used in business.
Return to Outline Copyright © 2009 by Maribeth H. Price 4-1 Chapter 4 Attribute Data.
NSF DUE ; Wen M. Andrews J. Sargeant Reynolds Community College Richmond, Virginia.
Selecting features in ArcMap
Microsoft Access 2000 Presentation 5 Creating Databases Part IV (Creating Queries)
Return to Outline Copyright © 2009 by Maribeth H. Price 5-1 Chapter 5 Queries.
# 1# 1 QueriesQueries How do we ask questions of the data? What is SELECT? What is FROM? What is WHERE? What is a calculated field? Spring 2010 CS105.
CENTENNIAL COLLEGE SCHOOL OF ENGINEERING & APPLIED SCIENCE VS 361 Introduction to GIS SPATIAL OPERATIONS COURSE NOTES 1.
Chapter 8- Queries What are queries? Extract certain records from a map or table Records meet certain criteria –Aspatial queries All parcels with value.
Retrieving Information Pertemuan 3 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
COM621: Advanced Interactive Web Development Lecture 11 MySQL – Data Manipulation Language.
DAY 20: ACCESS CHAPTERS 5, 6, 7 Larry Reaves October 28,
CHAPTER 10 DATA EXPLORATION 10.1 Data Exploration Box 10.1 Data Visualization Descriptive Statistics Box 10.2 Descriptive Statistics Graphs.
The data in the table.. Starting a query. Two criteria in an AND relationship.
Writing Simple Queries in Access
Chapter 5 Queries.
CSIS 115 Database Design and Applications for Business
Writing Basic SQL SELECT Statements
Chapter 4 Attribute Data.
Single Table Queries in SQL
ArcMap: Geoprocessing
Chapter 12 Information Systems.
Mastering ArcGIS Attribute Data (Continued)
Chapter 10 Geocoding.
Preliminaries: -- vector, raster, shapefiles, feature classes.
2-1 Making Decisions Sample assignment statements
Relational Operators Operator Meaning < Less than > Greater than
Using SQL with Access I am adding queries to the stu table in SecondDB.accdb – a database that I created in class. SQL stands for structured query language.
CSCE 315 – Programming Studio Spring 2010 Project 1, Lecture 4
Expressions.
Boolean Expressions to Make Comparisons
Relational Operators.
Topic 12 Lesson 2 – Retrieving Data with Queries
Shelly Cashman: Microsoft Access 2016
Decision Making Using the IF and EVALUATE Statements
Database Management Systems and Enterprise Software
Presentation transcript:

Mastering ArcGIS Chapter 7 Queries

What are queries? Extract certain records from a map or table Mastering ArcGIS Chapter 7 What are queries? Extract certain records from a map or table Records meet certain criteria Aspatial queries All parcels with value greater than $100,000 Spatial queries All parcels that lie completely within the flood plain Copyright © 2009 by Maribeth H. Price

SELECT *FROM FIELD WHERE Mastering ArcGIS Chapter 7 SQL Many databases use a special query language called Structured Query Language SELECT *FROM FIELD WHERE Copyright © 2009 by Maribeth H. Price 3

Mastering ArcGIS Chapter 7 SQL Query Examples Some Valid Queries SELECT *FROM cities WHERE "POP1990" >= 500000 SELECT *FROM counties WHERE “BEEFCOW_92” < “BEEFCOW_87” SELECT *FROM parcels WHERE “LU- CODE” = 42 AND “VALUE” > 50000 SELECT *FROM rentals WHERE “RENT” > 700 AND “RENT” < 1500 Programs may have an interface to help users build SQL expressions In most databases, SQL expressions are case-sensitive “Smith” ≠ “SMITH” Copyright © 2009 by Maribeth H. Price 4

Single criteria T A B Select students from T where [Home_State] = “NY” Mastering ArcGIS Chapter 7 Single criteria Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] T A B Select students from T where [Home_State] = “NY” Select students from T where [Major] = “Geography” Copyright © 2009 by Maribeth H. Price 5

Mastering ArcGIS Chapter 7 Queries as sets Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] T A Queries are used to extract subsets (records) of interest from a set (table) Multiple criteria may be used (such as Geography majors from New York) B C Copyright © 2009 by Maribeth H. Price 6

Mastering ArcGIS Chapter 7 Double criteria T Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] A B Select students from T where [Home_State] = “NY” OR [Home_State] = “NJ” Select students from T where [Home_State] = “NY” AND [Major] = “Geography” Copyright © 2009 by Maribeth H. Price 7

Mastering ArcGIS Chapter 7 AND vs OR? T A B C Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] Select students from T where [Home_State] = “NY” OR [Home_State] = “NJ” Select students from T where [Home_State] = “NY” AND [Major] = “Geography” Each condition is tested separately. If AND is used, then BOTH must be true. If OR is used, then either may be true. Copyright © 2009 by Maribeth H. Price 8

Boolean expressions AND and OR are Boolean operators Mastering ArcGIS Chapter 7 Boolean expressions AND and OR are Boolean operators Boolean operators are used to evaluate pairs of conditions Copyright © 2009 by Maribeth H. Price 9

Mastering ArcGIS Chapter 7 AND vs OR? T A B C Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] A AND B A B Select students from T where [Home_State] = “NY” AND [Major] = “Geography” Copyright © 2009 by Maribeth H. Price 10

Mastering ArcGIS Chapter 7 AND vs OR? T A B C Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] A OR B A B Select students from T where [Home_State] = “NY” OR [Major] = “Geography” Copyright © 2009 by Maribeth H. Price 11

Mastering ArcGIS Chapter 7 What do you get? T A B C Select students from T where [Major] = “Geography” OR [Major] = “English” B OR C Select students from T where [State] = “NY” AND [Major] = “English” A AND C Select students from T where [State = “NY” OR [Major] = “English” A OR C Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] Copyright © 2009 by Maribeth H. Price 12

Mastering ArcGIS Chapter 7 What do you get? T A B C Select students from T where [Major] = “Geography” AND [Major] = English” B AND C Select students from T where [AGE] > 20 AND [AGE] < 30 ? AND ? Select students from T where [AGE] > 20 OR [AGE] < 30 ? OR ? Let T = [all students in University] Let A = [students from New York] Let B = [AGE > 30] Let C = [AGE < 20] Copyright © 2009 by Maribeth H. Price 13

Other Boolean operators Mastering ArcGIS Chapter 7 Other Boolean operators Some databases use additional operators besides AND and OR A AND B A XOR B A NOT B A OR B A B Copyright © 2009 by Maribeth H. Price 14

What do you get? T A B C A AND B A OR B A XOR B A NOT B B AND A B OR A Mastering ArcGIS What do you get? Chapter 7 T A B C A AND B A OR B A XOR B A NOT B B AND A B OR A B XOR A B NOT A Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] Copyright © 2009 by Maribeth H. Price 15

Remember—you test each feature separately Mastering ArcGIS Chapter 7 Test: AND vs OR Remember—you test each feature separately Wrong Right “Land-use” = ‘RES’ AND “Land-use” = ‘COM’ “Land-use” = ‘RES’ OR “Land-use” = ‘COM’ “Pop2000” ≥ 5000 OR “Pop2000” < 9000 “Pop2000” ≥ 5000 AND “Pop2000” < 9000 Copyright © 2009 by Maribeth H. Price 16

Order of operations Boolean operators have equal order or precedence Mastering ArcGIS Chapter 7 Order of operations Boolean operators have equal order or precedence Evaluation occurs from left to right Parentheses must be used to change order Copyright © 2009 by Maribeth H. Price 17

What do you get? T A B C A AND B OR C ( A AND B ) OR C A AND (B OR C) Mastering ArcGIS Chapter 7 What do you get? T A B C A AND B OR C ( A AND B ) OR C A AND (B OR C) (A OR B ) AND C A OR (B AND C) A AND B A XOR B A NOT B A OR B A B Let T = [all students in University] Let A = [students from New York] Let B = [Geography majors] Let C = [English majors] Copyright © 2009 by Maribeth H. Price 18

Multiple conditions Test using these parcels RES COM $75,000 $75,000 Mastering ArcGIS Chapter 7 Multiple conditions Test using these parcels $75,000 $75,000 $75,000 $75,000 $125,000 $125,000 $125,000 $125,000 RES COM Copyright © 2009 by Maribeth H. Price 19

(“LU” = ‘RES’ or “LU” = ‘COM’) and “Value” > 100000 Mastering ArcGIS Chapter 7 Multiple conditions Test using these parcels (“LU” = ‘RES’ or “LU” = ‘COM’) and “Value” > 100000 $75,000 $75,000 $75,000 $75,000 $125,000 $125,000 $125,000 $125,000 RES COM Copyright © 2009 by Maribeth H. Price 20

“LU” = ‘RES’ or (“LU” = ‘COM’ and “Value” > 100000) Mastering ArcGIS Chapter 7 Multiple conditions Test using these parcels “LU” = ‘RES’ or (“LU” = ‘COM’ and “Value” > 100000) $75,000 $75,000 $75,000 $75,000 $125,000 $125,000 $125,000 $125,000 RES COM Copyright © 2009 by Maribeth H. Price 21