0% found this document useful (0 votes)
87 views31 pages

Database: Spatial Data GIS Database

The document discusses different types of databases and database management systems. It describes hierarchical, network, object-oriented, and relational database management systems. It also discusses spatial data formats like shapefiles, coverages, and geodatabases that can be used in GIS databases. Key characteristics of databases like users, interfaces, software, and data organization are outlined.

Uploaded by

ranjan08838
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views31 pages

Database: Spatial Data GIS Database

The document discusses different types of databases and database management systems. It describes hierarchical, network, object-oriented, and relational database management systems. It also discusses spatial data formats like shapefiles, coverages, and geodatabases that can be used in GIS databases. Key characteristics of databases like users, interfaces, software, and data organization are outlined.

Uploaded by

ranjan08838
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

02-08-2015

Database

Contour
Soil
Spatial Data
GIS Database
Landuse

Agriculture Census
Soil Type
Contour Heights Non Spatial
data

1
02-08-2015

Definition

A database is a shared collection of data


designed to meet the needs of multiple users. It
does not have to be computerized. However,
due to the high power and relatively low price
of current technology, as well as the
increasing availability of data prepared in the
digital form, most databases are intended for
computer use. Databases all share a number
of characteristics including those listed below.

Representing geographic features

• Vector
X,Y X,Y
X,Y
X,Y X,Y X,Y
X,Y
• Raster
Column

Row

• Data has

Behavior rules
Geometry
Attributes

1-4

2
02-08-2015

Introducing feature classes

• Collections of features with the same type of geometry


• Can create point, line, or area feature classes

primary
roads
Single linear
highways
feature class
“Roads”
secondary
roads

Many different line objects


5-5

Linking features and attributes


• Feature classes are tables that store spatial data
• Each feature has a record in the table
– Unique identifier links feature and attributes

FID = 5052
Feature Identifier

5-6

3
02-08-2015

Spatial data formats

• QGIS/ArcGIS can work with spatial data in multiple formats

Coverage
Shapefile Geodatabase

Internet Map
CAD Service

Raster Tables

QGIS/
ArcGIS
5-7

ESRI shapefile data format

• Shapefile
– Single feature class
– Attributes stored in dBASE table
– Made up of separate files
– Can create and edit with ArcGIS or ArcView 3.x
• Use only ArcCatalog to manage
shapefiles in arcgis
• Qgis explorer can handle shape files

5-8

4
02-08-2015

ESRI coverage data format

• Coverage
– Multiple feature classes
– Attributes stored in INFO table
– Can only be stored in an ArcGIS Workspace
– Edited only with ArcInfo Workstation
• Use only ArcCatalog to manage coverages

5-9

CAD file data format

• Computer Aided Design files (DXF, DWG, DGN)


• Logical collection
– Display one or all feature classes
• Edit after converting to geodatabase FC or shapefile
CAD file (read-only attribute tables)

Shape field
accesses read-only
coordinates

5-10

5
02-08-2015

QGIS data format

• QGIS allows use of dxf, shapefiles, coverages, KML, and


personal geodatabases. MapInfo, PostGIS (postgreSQL, and a
number of other formats are supported in QGIS. Web services,
including Web Map Service and Web Feature Service, are also
supported to allow use of data from external sources.

Attributes Database

Metadata

6
02-08-2015

Terms in Database

• User group: The group of people accessing the data whether


for reading, add, delete, or modify.
• System interface: The method of communicating with the
database management system which can be a high-level
programming language or a set of menus.
• Database software: The software that physically executes all
user requests made through the system interface.
• Database dictionary: The physical repository of all data about
the database contents, such as data definitions.
• Database: The physical repository of all user-required data.
• Database administration: The organizational group
responsible for the control of data and overall direction of the
database function.

DBMS: To manage a data base, you need specific software, called a


Data Base Management System (DBMS), such as ORACLE, DBASEIV,
etc. A DBMS acts as the central control over all interactions between the
data base and applications (or application program), which in turn
interact with the user via a user-interface.

The principal characteristics of a DBMS are


– Centralized control over data base is possible, allowing for a better quality
management, and operator defined access to parts of the data base.
– Data can be shared effectively by different users for different application
– The access to the data is much easier, due to the use of a user-interface, an
– the user-views (specially designed formats for entering and consulting the
data base).
– Data redundancy (storage of the same data in more than one place in the
database) can be avoided as much as possible. Redundancy, or
unnecessary duplications of data, are an annoyance, since it makes the
updating of a data base much more difficult. One can overlook easily to
change redundant information in all places where it occurs.
– The creation of new applications is much easier with a DBMS.

• The disadvantages relate to the higher cost of purchasing the software,


the increased complexity of management, and the higher risk, as data is
centrally managed.

7
02-08-2015

DATABASE MANAGEMENT
SYSTEM
• Hierarchical Database Management System
• Network Database Management System
• Object Oriented Database Management System
• Relational Database Management System

Hydro Meteorological Data

KTM KTM

Note that the relationship is always from one to many;


the model does not support from many to one.

8
02-08-2015

Hierarchical database
• A hierarchical database organizes data as one object of interest related to many
other objects of interest. The tree-like structure. produced is referred to as an
ordered set of parent/child relationships. In this model, a parent can have one or
more children. Child cannot have more than one parent. When real world’ data
relationships are of this type, the hierarchical model is an effective representation
model.
• Hierarchical are familiar relationships. Examples are plant and animal
taxonomies, a dendritic river drainage pattern, and the organization of a file
cabinet into several drawers, each of which contains a number of folders which
may contain one or more documents, and so on. Note that the relationship is
always from one to many; the model does not support from many to one.
• The hierarchical model includes an implementation strategy that requires the
extensive use of physical pointers. These pointers become part of the data
structure and are therefore explicit. That is, the relationships that are believed to
exist become hard-wired into the implementation. This may make a hierarchical
database very efficient in processing data demonstrating such a relationship, but
very difficult to process data which does not conform

• Network database extend the hierarchical model and allow from many to one
relationships to be represented. Street patterns, shown in the graphic above, illustrate
networks. When modelled in this way, many streets can be associated with one
intersection. The network and the hierarchical model makes extensive use of physical
pointers to identify relationships. Because of the requirements to traverse the
database along physical pointers, hierarchical and network databases have an
embedded implementation scheme.
• The network model is very effective in management of geographic information,
especially for establishing linear features and their relationships

9
02-08-2015

Landuse

Forest Agriculture Water body

• In this model the data re arranged in classes and sub-classes, which are a set of
objects grouped into categories and with link of various kinds. All objects in the
same class share a set of properties (attribute) and methods (requests)
• The above diagram is normally termed as object model diagram, which illustrates
relationships among classes. The diagram depicts inheritance type of relationship.
Inheritance relationships illustrate the Is Kind Of relationship and allow for a
progressive refinement of classes from the more general to the more specific.
Super-classes define more general aspects which subclasses inherit and further
define additional more specific characteristics and behavior. When looking for a
particular request or attribute, search the class and then also the super-classes.
• The categories inherit hierarchically the properties and methods of the class in the
preceding rank. For example, a deciduous forest sub-class will inherit the
properties and methods of the forest class.
The principles of object-oriented databases are aimed at overcoming some of the
disadvantages f classic structured (in particular the layer based system). The
object-oriented programming make use of the above concept. Typically, behave a
format like this: Object .Request

10
02-08-2015

What is Relational Database?

• Organizes data in tables (or relations)


• Proposed by Edgar Codd

• Structured Query Language (SQL)

Relational Database

1. A relational database is a perception of data as collections


of tables that are logically associated to each other by
shared attributes.
2. A relation can represent all the information that can be
represented in a hierarchy with one less data object, a
physical pointer.
3. Any data element can be found in a relation by knowing the
table name, the attribute (column) name, and the value of
the primary key.
The advantage of these systems is that they are very
flexible and can reply to any kind of query formulated with
logical and mathematical operations.

11
02-08-2015

• A relational database s a collection of files that are perceived as two-


dimensional tables. The columns are referred to as attributes and
the rows are termed tuples. or occurrences. The value for any
attribute is termed an entry and is the smallest unit of data within the
database. That is, an entry cannot be reduced to a smaller structure
without loss of information. For example, if the smallest unit of data
is name, then the entry RAM cannot be reduced to a set of individual
characters, R A M, and still maintain the original meaning.

• The table construction is used in several areas other than relational


database systems. Spreadsheets, arrays, and statistical matrices
are, for example, structured in this way. In these other areas there is
a different terminology, however. Within an array, an individual value
is termed an element; while within statistics, rows, or observations,
are distinguished from columns, or variables. These are not
necessarily relational structures, however, since in addition, a
relational table, or relation, must conform to the following six
properties:

• • Each column, termed an attribute, has a unique name.


• The left-to-right order of columns is irrelevant.
• Each attribute entry is single valued; no repeating groups or arrays are
allowed.
• Entries in any one column are of the same kind.
• The top-to-bottom order of rows is also irrelevant.
• Each row is unique, and is called a record

12
02-08-2015

Single Table Database (Page 53)

Phone book example

Field

Name Mobile Number Landline Number


Gwen 09981112233 9144321 Record
Randy 09984445566 7984699

Integer – ex. 1, 10, 1051


Floating-point – ex. 2.57, 754.1256
String – ex. “Ongoing”, “Done”
Date/Time - 6/29/2015
Binary - photos

Single Table Database Design Example

Database Design - The process of producing a detailed data model


of a database
•Design Contact Information with Name, Address, and Phone
Number

Robert Santos, 100 Rosal St, Rosario, Pasig, 2298310


Gwen Cruz, 253 Alice St, Greenhills, San Juan, 4992122
James Del Sol, 9 Jay St, Concepcion, Marikina, 4893892
Alice Tolentino, 71 Rizal St, Concepcion, Marikina, 5050011

Sort:
Alice Tolentino, 71 Rizal St, Concepcion, Marikina, 5050011
Gwen Cruz, 253 Alice St, Greenhills, San Juan, 4992122
James Del Sol, 9 Jay St, Concepcion, Marikina, 4893892
Robert Santos, 100 Rosal St, Rosario, Pasig, 2298310

13
02-08-2015

Single Table Database Design Example

• Revision of Design
Cruz, Gwen, 253 Alice St, Greenhills, San Juan, 4992122
Del Sol, James, 9 Jay St, Concepcion, Marikina, 4893892
Santos, Robert, 100 Rosal St, Rosario, Pasig, 2298310
Tolentino, Alice, 71 Rizal St, Concepcion, Marikina, 5050011

Cruz, Gwen, 253 Alice St, Greenhills, San Juan, 4992122


Del Sol, James, 9 Jay St, Concepcion, Marikina,
4893892
Santos, Robert, 100 Rosal St, Rosario, Pasig, 2298310
Tolentino, Alice, 71 Rizal St, Concepcion, Marikina,
5050011

Single Table Database Design Example


Cruz, Gwen, 253 Alice St, Greenhills, San Juan, 4992122
Del Sol, James, 9 Jay St, Concepcion, Marikina, 4893892
Santos, Robert, 100 Rosal St, Rosario, Pasig, 2298310
Tolentino, Alice, 71 Rizal St, Concepcion, Marikina, 5050011

From
name, address, phone number

To
last name, first name, street address, municipality, phone number

14
02-08-2015

Multi-table Database

• Each of the tables will be linked to one or more of the other tables
• Multi-file databases like this are called relational databases
• Relational databases are made up of two or more tables of
information which are connected in some way.

Customer
Primary key CustomerID FirstName LastName Address Birthday
1 Robert Santos Rosario, Pasig 9/15/1980
2 Gwen Cruz Greenhills, San Juan 2/28/1985
3 James Del Sol Concepcion, Marikina 5/1/2000

Order
CustomerID Item Quantity Price
1 Shoes 1 2,950.00
Foreign key
2 Blouse 1 849.00
1 Belt 1 499.00
3 Wrist Watch 1 1,999.00

Database Indexing

• database index is a data structure that improves the speed of


data retrieval operations on a database table at the cost of slower
writes and the use of more storage space. Indexes can be created
using one or more columns of a database table, providing the
basis for both rapid random lookups and efficient access of
ordered records.

15
02-08-2015

• In a relational database, an index is a copy of


one part of a table. Some databases extend the
power of indexing by allowing indices to be
created on functions or expressions. For
example, an index could be created on
upper(last_name), which would only store the
upper case versions of the last_name field in the
index. Another option sometimes supported is
the use of "filtered" indices, where index entries
are created only for those records that satisfy
some conditional expression. A further aspect of
flexibility is to permit indexing on user-defined
functions, as well as expressions formed from an
assortment of built-in functions.

About Relationships in a Database

A relationship works by matching data


in key fields - a field with the same
name in both tables
1. One-to-one relationship (1:1)
2. One-to-many relationship (1 :m)
3. many-to-many-relationship (m:m)

16
02-08-2015

Relationships among tables


Customer Address
• One-to-one CustomerID ID
Name Street
Address_ID City
Region

Customer Item
• one-to-many CustomerID ItemID
Name Name
Item Description
Quantity UnitPrice
Price

• Many-to-many IDLot Number ID


Tenant
ID
Farmer

LotCode LotCode Name


LotNumber LotNumber Address
Area FarmerID

One to one relationship

17
02-08-2015

• Each record in Table A can have


only one matching record in Table B and vice-versa
• like dividing a table

One to Many relation

Most common type

A record in Table A can have many


matching records in Table B,
but a record in Table B
has only one matching record
in Table A

18
02-08-2015

Many to Many Relationship

Costumer Table
Product Detail Table
Order_ID CustmerID EmployeeID
Item_
Product_ID Product_Name Price 10000 Ram 6
Saving cream 10001 Syam 8
104 zelate 68
10002 Gopi 3
108 Nescafe 106
10003 Hari 3
122 Panasonic Radio 111
110 Freeze samsung 32000
Order_ID Product_ID quantity
Order Detail Table 10001 104 3
10001 108 19
10001 122 2
10003 104 10
Summary Table 10003 110 5

Coustmer Name Order Id No of Total Price Employee id


item
Shyam 1001 3 2440 8

19
02-08-2015

Steps in Relational Database Design

• Define the Purpose of the Database

• Gather Data, Organize in tables and Specify the Primary Keys

• Create Relationships among tables

• Refine and Normalize the Design

What is Normalization?
• Normalization is the process of efficiently organizing data in a
database. There are two goals of the normalization process:
eliminating redundant data (for example, storing the same data in
more than one table) and ensuring data dependencies make
sense (only storing related data in a table). Both of these are
worthy goals as they reduce the amount of space a database
consumes and ensure that data is logically stored.
• The database community has developed a series of guidelines for
ensuring that databases are normalized. These are referred to as
normal forms and are numbered from one (the lowest form of
normalization, referred to as first normal form or 1NF) through five
(fifth normal form or 5NF). In practical applications, you'll often see
1NF, 2NF, and 3NF along with the occasional 4NF. Fifth normal
form is very rarely seen.

20
02-08-2015

Normalization contd
Customer
CustomerID* FirstName LastName Address Birthday
1 Robert Santos Rosario, Pasig 9/15/1980
2 Gwen Cruz Greenhills, San Juan 2/28/1985
3 James Del Sol Concepcion, Marikina 5/1/2000

Order
CustomerID Item Quantity Price
1 Shoes 1 2,950.00
2 Blouse 1 849.00
1 Belt 1 499.00
3 Wrist Watch 1 1,999.00

• First normal form (1NF) sets the very basic rules for an organized
database: Eliminate duplicative columns from the same table.
• Create separate tables for each group of related data and identify
each row with a unique column or set of columns (the primary key).
• First Normal Form (1NF): A table is 1NF if every cell contains a
single value, not a list of values.

Normalization

Customer
CustomerID* FirstName LastName Address Birthday
1 Robert Santos Rosario, Pasig 9/15/1980
2 Gwen Cruz Greenhills, San Juan 2/28/1985
3 James Del Sol Concepcion, Marikina 5/1/2000

• Second Normal Form (2NF): A table is 2NF, if it is 1NF and every


non-key column is fully dependent on the primary key.
• Second normal form (2NF) further addresses the concept of
removing duplicative data: Meet all the requirements of the first
normal form.
• Remove subsets of data that apply to multiple rows of a table and
place them in separate tables.
• Create relationships between these new tables and their
predecessors through the use of foreign keys.

21
02-08-2015

Third Normal Form (3NF)

• Third normal form (3NF) goes one large step further: Meet all the
requirements of the second normal form.
• Remove columns that are not dependent upon the primary key
(the non-key columns are independent of each other)

Integrity Rules

Customer
CustomerID* FirstName LastName Address Birthday
1 Robert Santos Rosario, Pasig 9/15/1980
2 Gwen Cruz Greenhills, San Juan 2/28/1985
3 James Del Sol Concepcion, Marikina 5/1/2000

• Entity Integrity Rule: The primary key cannot contain NULL

22
02-08-2015

Integrity Rules
Customer
CustomerID* FirstName LastName Address Birthday
1 Robert Santos Rosario, Pasig 9/15/1980
2 Gwen Cruz Greenhills, San Juan 2/28/1985
3 James Del Sol Concepcion, Marikina 5/1/2000

Order
CustomerID Item Quantity Price
1 Shoes 1 2,950.00
2 Blouse 1 849.00
1 Belt 1 499.00
3 Wrist Watch 1 1,999.00

• Referential Integrity Rule: Each foreign key value must be


matched to a primary key value in the table referenced (or parent
table).

Integrity Rules

• Business logic Integrity: Integrity (validation) pertaining to the


business logic, e.g.:
– zip code shall be 5-digit within a certain ranges
– delivery date and time shall fall in the business hours
– quantity ordered shall be equal or less than quantity in stock
– etc

23
02-08-2015

Column Indexing

• Speeds up data access for SELECT

• Slows down INSERT, UPDATE, and DELETE

Multi-table Design Example

We’ll design a database to keep track of athlete’ sports activities.


We’ll track each activity an athlete takes and the annual fee to do that
activity.

Step 1: Create an Activities table.


Athlete, Activity 1, Cost 1, Activity 2, Cost 2.
Step 2 & 3: Test the table with some sample data and analyze

Activities Table
Athlete Activity1 Cost1 Activity2 Cost2
Robert Santos Tennis 3,600 Swimming 1,700
Problem? Gwen Cruz Weightlifting 1,000 Swimming 1,700
Robert Santos Tennis 3,600
James Del Sol Swimming 1,500 Golf 4,700

24
02-08-2015

Uniquely Identify Records

Step 4: Modify the design.


ID*, Activity 1, Cost 1, Activity 2, Cost 2

Step 5: Test the table with sample data.

Athletes Table Activities Table


Athlete ID* ID* Activity1 Cost1 Activity2 Cost2
Robert Santos 8 8 Tennis 3,600 Swimming 1,700
Gwen Cruz 10 10 Weightlifting 4,000 Swimming 1,700
Robert Santos 18 18 Tennis 3,600
James Del Sol 21 21 Swimming 1,500 Golf 4,700

Uniquely Identify Records


Athletes Table Activities Table
Athlete ID* ID* Activity1 Cost1 Activity2 Cost2
Robert Santos 8 8 Tennis 3,600 Swimming 1,700
Gwen Cruz 10 10 Weightlifting 4,000 Swimming 1,700
Robert Santos 18 18 Tennis 3,600
James Del Sol 21 21 Swimming 1,500 Golf 4,700

Step 6: Analyze the data (Problem with Activities table)


• Some athletes don’t take a second activity - wasted space
• What if James Del Sol wants to do a third activity?
• What if tennis fees go up to php3,900
• It’s difficult to find all people doing swimming
• If 50 athletes take swimming, we have to type in both the
activity and its cost each time.
• Inconsistent cost of swimming

25
02-08-2015

Eliminate Recurring Fields

Step 7 & 8: Modify the design and test sample data- Eliminate the
Activity 2 and Cost 2 fields
Athletes Table Activities Table
Athlete ID* ID* Activity Cost
Robert Santos 8 8 Swimming 1,700
Gwen Cruz 10 8 Tennis 3,600
Robert Santos 18 10 Weightlifting 4,000
James Del Sol 21 10 Swimming 1,700
18 Tennis 3,600
21 Golf 4,700
21 Swimming 1,500
21 Weightlifting 4,000

Eliminate Data Entry Anomalies


Athletes Table Activities Table
Athlete ID* ID* Activity Cost
Robert Santos 8 8 Swimming 1,700
Gwen Cruz 10 8 Tennis 3,600
Robert Santos 18 10 Weightlifting 4,000
James Del Sol 21 10 Swimming 1,700
18 Tennis 3,600
21 Golf 4,700
21 Swimming 1,500
21 Weightlifting 4,000

Step 9: Analyze the data. (Problem with Activities table)


•Redundant Activity/Cost entry
•Inconsistent cost of swimming
•Can’t insert new activity
•Can’t delete an athlete

26
02-08-2015

Multi-table Design Example

Step 10: Modify the design


•The remaining problem is that we have a non-key field (cost) which
is dependent on only part of the key (activity). The cost of each
activity is not dependent on the athlete’s ID but in an activity only.
Our final design will thus contain three tables: the Athletes table
(Athlete, ID), a Participants table (ID, Activity), and a modified
Activities table (Activity, Cost).
Step 11: Test sample data.
Athletes Table Participants Table Activities
Athlete ID* ID* Activity Activity* Cost
Robert Santos 8 8 Tennis Golf 4700
Gwen Cruz 10 8 Swimming Sailing 5000
Robert Santos 18 10 Weightlifting Weightlifting 4000
James Del Sol 21 10 Swimming Swimming 1500
18 Tennis Tennis 3600
21 Golf
21 Swimming
21 Weightlifting

Multi-table Design Example


Athletes Table Participants Table Activities
Athlete ID* ID* Activity Activity* Cost
Robert Santos 8 8 Tennis Golf 4700
Gwen Cruz 10 8 Swimming Sailing 5000
Robert Santos 18 10 Weightlifting Weightlifting 4000
James Del Sol 21 10 Swimming Swimming 1500
18 Tennis Tennis 3600
21 Golf
21 Swimming
21 Weightlifting

Step 12: Analyze the results.


•No redundant information
•No inconsistent data
•No insertion anomalies
•No deletion anomalies

27
02-08-2015

4.3.10. Summary of Design Process

• Break composite fields down into constituent parts.

• Create a key field which uniquely identifies each record.

• Eliminate repeating groups of fields.

• Eliminate record modification problems (such as redundant or


inconsistent data) and record deletion and addition problems by
ensuring each non-key field depends on the entire key.

Exercise

Create a database design for farmer’s irrigation service fee (ISF).


The design will be based on the following information:

Farmer LotCode Area(ha) Crop Year ISF(php)


Juan Manuel Marquez 1001-1 0.15 Rice 2013 382.50
Miguel Cotto 1001-3 0.20 Corn 2013 450.00
Antonio Barrera 1001-2 0.08 Rice 2013 204.00
Antonio Margarito 1001-4 0.05 Corn 2013 112.50
Juan Manuel Marquez 1001-1 0.10 Rice 2012 255.00

Condition:

•LotCode is Primary key (unique)


•Rate of Rice is 150kg/ha and Government Support Price (GSP) of php17.00
•Rate of Corn is 150kg/ha and GSP of php15.00
•ISF of Rice is Area x Rate x GSP (ex. 0.15 x 150 x 17 = 382.50)
•Design should be sortable by last name
•Established Table Relationships

28
02-08-2015

Types of Variable/Fields in ArcGis


1. Name Type in the name of the new field. Field names cannot contain
square brackets ( [ ] )
2. Type Use this box to choose the type of field you wish to add to the
table. The possible types are:
1. Number. Specify the width of the field in digits in the Width field, and the
number of decimal places in the Decimal Places field. Typing 0 will make
the field an integer.
2. String. Specify the width of the field in characters in the Width field
3. Boolean. Each value in a Boolean field is either True or False. When you
type values into a Boolean field you can either type True or False in full, or
just type t or f which ArcView will immediately convert to True or False for
you.
4. Date. Each value in a date field is eight digits in the format YYYYMMDD.
For example, the 2nd of May 1961 would be represented as 19610502.
When you type dates into a date field they must be in this format.

Types of Variable/Fields in QGIS


1. Name Type in the name of the new field. Field names cannot contain
square brackets ( [ ] ), not more than 11 character and no space
2. Type Use this box to choose the type of field you wish to add to the
table. The possible types are:
1. Number. (whole number and real number)Specify the width of the field in
digits in the Width field, and the number of decimal places in the Decimal
Places field. Typing 0 will make the field an integer.
2. Text. Specify the width of the field in characters in the Width field

3. Date. Each value in a date field is 10 digits in the format.2014-05-27

29
02-08-2015

SQL
• SQL is an industry standard database query language used to
fetch records from tables and to present those records with the
fields desired. SQL may also be used to create new tables by
combining existing tables, and may even be used to alter the
structure of the database and the data it contains.
• Select queries show results in tables and always begin with
the SQL word select. Select queries choose data from one or
more tables and display it in tabular form. Select queries do
not change any data in the tables.
SELECT * FROM PARCELS WHERE PROPCLASS =
210
• Action queries do not display data but rather perform a task
when they are run. Action queries change data in existing
tables by appending, updating or deleting records. Action
queries can also create new tables. Action queries start with
words other than select. For example, an update query starts
with the word Update.
UPDATE PARCELS SET PROPCLASS = 210

SQL

–For ARCGIS Geo database


• For text: wild card *, for one character = ?
• Case not sensitive
[district] = “B*”, [district] = “S????i”
[district] = ‘B*’, [district] = ‘S????i’
• For number > = and others

–For Shape file for QGIS


• For Text: wild card % for one character = _
• Case sensitive
“district” like ‘B%’, “district” like ‘S_____i’

30
02-08-2015

SQL with Spatial Extensions


• Perhaps the most powerful advantage of using
SQL with GIS is when you can add spatial
criteria too. For example, in addition to meeting
some attribute query, we can also meet a
spatial query
SELECT PARCELS.* FROM PARCELS,
WATER WHERE PROPCLASS = 210 AND
DISTANCE(PARCELS.ID, WATER.ID) <
300
This query selects the parcels that meet the
property class criteria in addition to being within
a particular distance of another feature.

Selection of Texts in Qgis shape files

• Select Text starting with F,


– SQL: “Text_field” like ‘F%’
• Select Text starting with F, and end
with a
– SQL: “Text_field” like ‘F%a’
• Select Text starting with F and of five
character
– SQL: “Text_field” like ‘F____’

31

You might also like