Sunteți pe pagina 1din 67

GIS Database Development

Dr Abdullah Hisam Omar


Databases Before the Use of
Computers
 Data kept in books, ledgers, card files,
folders, and file cabinets
 Use pin maps
 Long response time
 Labor-intensive
 Often incomplete or inaccurate
Common Problems with Using
Files
 Uncontrolled duplication
– Wastes space
– Hard to update file all files
 Inconsistent data
 Inflexibility
 Limited data sharing
 Poor enforcement of standards
 Poor programmer productivity
 Excessive program maintenance
Database Management
System

All Data

DBMS

Program 1 Queries Program 2


and
Reports
Why do we need a DBMS?
 The user does not need to know the specific
structure of the data in the database;
 Different users can have their own “view” of
the database to suit their own needs;
Why do we need a DBMS? (2)
 The DBMS will allow interfaces to be
created in a variety of programming
languages;
 You can customize the database so that
regularly used data can be retrieved faster;
 Security and Statistics.
The Database Approach
 Database-management system (DBMS)
– Interact with the data in databases
 Entity: something you collect data about
 Field: one characteristic of an entity
 Record: collection of fields that describe one
occurrence of an entity
 Entities stored in tables
– One record per row
– One field per column

7
Components of a DBMS

 Database engine
 Data dictionary
 Query processor
 Report writer
 Forms generator
 Application generator
 Communication
 Security
Sample Data Table
The Database Approach
 DBMS replaced file processing approach
– Reduced data redundancy
– Reduced program dependence
 Databases typically consist of several tables
 Tables can be linked together
Advantages of a DBMS

 Minimal data redundancy


 Data consistency
 Integration of data
 Sharing of data
 Enforcement of standards
 Ease of application development
 Uniform security, privacy, and integrity
 Data independence
Database operations
 Adding data,
 Deleting data,
 Amending data.
 (data are records or files...
more on this later).
Data Structure
 Data model
– A representation of the entities and their
relationships
 Primary key
– An attribute or combination of attributes
– Uniquely identifies each record
Data Type
 Each field is assigned a type
– Text, number, date, etc.
 Data types help the DBMS
– Organize and sort the data
– Do calculations
– Allocate space
 Data dictionary
– A repository of information about the data
– Key fields, data types, valid values, etc.

14
Database Management
Systems Approaches
 Models of the relationship between entities
in a database
– Hierarchical
– Network
– Relational
– Object -Oriented
The Hierarchical Model
The Network Model
Database Fundamentals - Object-Oriented
Model
 Object-Oriented Paradigm
– Programming Languages
– Analysis and Design Methodologies
– Databases and DBMS
 O-O Advantages
– More modeling power
– Additional constructs
– Better transition to implementation models
Database Fundamentals - Object-Oriented
Model

 O-O Applications
– CAD, Office Information Systems, CASE
tools, GIS
– Structurally complex information, specialized
graphics, non-standard transactions
Database Fundamentals - Object-Oriented Model

 O-O DBMS
– Standard DBMS capabilities
 Scheme management
 Query language and optimization
 Storage and access management
 Transaction management
 Persistence
Database Fundamentals - Object-Oriented
Model

 Summary
– The O-O model is more flexible for
representing natural (dynamic) objects in the
real world than the E-R model
– The O-O model provides less of an impedance
mismatch
 Allows the conceptual data model and the user’s
view of the application domain to be closer to the
logical model and the system implementation
Database software...
 Light Duty

 Medium Duty

 Heavy Duty
Database Tables

Database

Table1 Table2 Table3


Structure
Column 1 Column 2
(Field 1) (Field 2)
Row 1 Value
(Record 1)
Row 2
(Record 2)
The Relational Model
 Views entities as two-dimensional tables
– Records are rows
– Attributes are columns
 Tables can be linked
 Supports one-to-many, many-to-many, and one-to-one relationships
 Entity: “Thing” in the real world with an independent
existence.
- An entity-an object with a physical existence--
particular person, car, house or employee
- An entity- an object with a conceptual existence –
a company, a job, or a university course
- Each entity has particular properties called attributes
Entity
Entity

Name= Abu Bakar Owner= Bakar Talib

Employee Address= UTM


Lot Address= Jln 1, Tmn Pulai

Age= 55 Age= 45
Attribute

Phone= 07-2555555 Phone= 07-3366333

Attribute
The Relational Model
ER-DIAGRAM : example
Jen_Gunaan Na_Jalan
Lebar
Jen_Bangunan Id Panjang

Na_Jalan
LOT bersebelahan JALAN Laluan

Polygon G T Line G
Risiko
1 T
Kelas
No_Rumah
bersebelahan
bersebelahan
berdekatan

ID m Tekanan
No_PB
PARIT PILI BOMBA
Point G Trkh_Servis
Polygon G Lokasi
T T
Na_Jln Status

Zon Taraf

E-R Diagram
Schema
 The structure of a database described in a
formal language.
 Generally stored in the data dictionary.
 The term is often used to refer to a graphical
depiction of the database structure.
 In a RDBMS, the schema defines the tables,
the fields in each table, and the relationships
between fields and tables.
Example..Schema

PENGUNDI
No_KP Taraf Nama Kawasan Kerja

PEKERJAAN
No_KP Kerja Gaji Tempat Status

AKAUN
No_Akaun Bank Cawangan No_Kp ID_Sec
Fields and Records
 Field: An element
First Name Last Name
of a table that
contains a specific 1 Amanda Huginkiss
item of
2 I.P. Freely
information;
 Record: A 3 Al Coholic
collection of data 4 Ivona Tinkie
about a person, an
event, etc.
RDBMS (Relational DBMS)
 a type of database management
system(DBMS) that stores data in the form
of related tables.
Why RDBMS?
 Relational databases are powerful because
they require few assumptions about how data
is related or how it will be extracted from the
database.
 As a result, the same database can be viewed
in many different ways.
 A single database can be spread across
several tables.
Relational Database
Relations
Keys

• Candidate Keys
• Primary Keys
• Alternate Keys
Foreign Keys
A foreign key on relation A is a primary key on relation B.
What are attribute data?
“Positional data are the ‘where things are’ data
and attribute data the ‘what things are’ ”.

 Data about our world are being produced


continuously.
– Satellites
– automatic environmental monitoring
– automated business transactions
– everyday activities; purchasing, banking
– research and surveys
Attribute Data Types used in
GIS
Data types used in a GIS include:
• character strings (Idaho, Moscow)

• integers (4387, -92)

• floating points (56.23, 0.03)

• dates (10012001)

• time (0930, 1458)


Database Implementation

Database implementation
is the procedure of
populating the database
with attribute data.
The Design Process of Database
Needs Analysis
Data investigation is the “fact-finding” stage of database creation.

Consider:
• data types
• data quantity
• data quality
• attribute nature
• entity nature
Conceptual Design:
Modeling the Relationships between
Entities

 One to one; 1:1


– one visitor stays at one hotel
 One to many; 1:M
– one ski school teaches many visitors
 Many to many; M:N
– many tour companies use many hotels
Creation of the Database

(Heywood et al., 1998)


Attribute Data Modeling

(Heywood et al., 1998)


Conceptual Design
Entity Relationship Model (E-R)
GPS_Stn
Pelan_Lokasi GPS_Stn
1 Koordinat WGS_Lat
Pelan_Akui Status
Geodetik
Monumen WGS_Lon
Sketch R_East
1 Divide to
Tarikh_Bina Kawalan R_North RSO_X RSO_Y

GPS Negeri
GPS_Stn
Seksyen 1 Koordinat
Mukim Daerah WGS_Lat
1
Geosentrik
WGS_Lon
Control Monumen
R_East
R_North RSO_X RSO_Y
CCDB_Stn Status
GPS_Stn
1 1 CCDB_Stn
Tarikh
Update
Koordinat
Pointkey Geodetik WGS_Lat
1 Kawalan 1
Divide to
Coincide WGS_Lon
Kadaster R_North RSO_X
R_East RSO_Y
Negeri
Pelan_Lokasi M 1

Skecth Seksyen Daerah


Koordinat CCDB_Stn
R_East
Pelan_Akui Geosentrik
Control Mukim WGS_Lat
1 R_North
Apdate RSO_X RSO_Y WGS_Lon
Negeri Daerah
Pointkey Mukim Svy_Area
Mark_Desc
Apdate Parcelkey Bearing
Lot_No N
GID Area_Unit
Serial Plan Distance
M 1 1 M
Batu has has Garis Units
S_Comment LOT Class
Sempadan GID Sempadan
GID Line_Code
Status Coord_Type Apdate Status
Adjparcel Line_Type
R_East R_North Lock_Id
Status
Entry_Mod Tnode Fnode
GPS_Stn
Pelan_Lokasi GPS_Stn
1 Geodetic WGS_Lat
Pelan_Akui Status
Coordinates
Monumen WGS_Lon
Sketch R_East
1 Divide to
Tarikh_Bina GPS R_North RSO_X RSO_Y

Control Negeri
GPS_Stn
Seksyen 1 Geocentric
Mukim Daerah WGS_Lat
1
Coordinates
WGS_Lon
Control Monumen
R_East
by R_North RSO_X RSO_Y
CCDB_Stn Status
GPS_Stn
1 1 CCDB_Stn
Tarikh Geodetic
Update
Pointkey Coordinates WGS_Lat
1
Cadastral 1
Divide to
Coincide WGS_Lon
Cadastre R_North RSO_X
R_East RSO_Y
Negeri
Pelan_Lokasi M 1

Skecth Seksyen Daerah


Geocentric CCDB_Stn
R_East
Pelan_Akui Coordinates
Control Mukim WGS_Lat
1 R_North
by
Apdate RSO_X RSO_Y WGS_Lon
Negeri Daerah
Pointkey Mukim Svy_Area
Mark_Desc
Apdate Parcelkey Bearing
Lot_No N
GID Area_Unit
Serial Plan Distance
M 1 1 M
Boundary has has Boundary Units
S_Comment LOT Class
Mark GID Line
GID Line_Code
Status Coord_Type Apdate Status
Adjparcel Line_Type
R_East R_North Lock_Id
Status Tnode Fnode
Entry_Mod
Logikal Design

• Translation of the conceptual design to database.


• Based on selected DBMS
•Example of logical design in MapInfo 5.0

Struktur jadual dalam perisian MapInfo


LOGICAL DESIGN
Master Data List
Feature Object Class Object Class Type Geometry
Dataset Name Alias
DCDB Sto Batu Sempadan Simple Point

Bdy Garis Sempadan Simple Polyline

Lot Parcel Simple Polygon

Rujukan GPS Stesen GPS Simple Point


Geodetik CCDB Kawalan Kadaster Simple Point

None GPSgeod Koordinat Table None


Geodetik GPS
GPSgeos Koordinat Table None
Geosentrik GPS
CCDBgeod Koordinat Table None
Geodetik CCDB
CCDBgeos Koordinat Table None
Geosentrik CCDB
FIELD FOR FEATURE CLASS

STO LOT
BRY
-NEGERI
-POINTKEY (Primary Key)
-APDATE -DAERAH
-APDATE
-PARCELKEY -MUKIM
-MARK_DESC
-BEARING -SEKSYEN
-SERIAL -LOT
-DISTANCE
-COORD_TYPE -SVY_AREA
-UNITS
-R_EAST -CLASS -AREAUNIT
-R_NORTH -LINE_CODE -APDATE
- S_COMMENT -LINE_TYPE -STATUS
-STATUS -ENTRY_MOD -LOCK_ID
-GID -PLAN -GID
-FNODE
-TNODE
-ADJPARCEL
-STATUS
FIELD FOR TABLE
CCDBgeodCCDBgeod
GPSgeod -OBJECT_ID
-OBJECT_ID -CCDB_STN (Foreign
Key)
-GPS_STN (Foreign Key)
-WGS_LAT
-WGS_LAT
-WGS_LON
-WGS_LON
-RSO_Y
-RSO_Y
-RSO_X
-RSO_X
-R_NORTH
-R_NORTH
-R_EAST
-R_EAST
CCDBgeos
GPSgeos
-OBJECT_ID
-OBJECT_ID
-CCDB_STN (Foreign
-GPS_STN (Foreign Key) Key)
-WGS_LAT -WGS_LAT
-WGS_LON -WGS_LON
-RSO_Y -RSO_Y
-RSO_X -RSO_X
-R_NORTH -R_NORTH
-R_EAST -R_EAST
Physical Design

 Proses pemilihan struktur penyimpanan data dan laluan


capaian bagi fail pangkalan data untuk mendapatkan
persembahan yang baik.

 Semua pangkalan data akan disimpan dalam personal


geodatabase masing-masing mengikut negeri dan storan setiap
personal geodatabase adalah seperti berikut :-
 Melaka – 132 MB
 Wilayah Persekutuan – 214 MB
Rekabentuk Fizikal

• proses pemilihan struktur penyimpanan dan laluan


capaian
• penyimpanan fail merujuk kepada jumlah data
• ruang storan berdasarkan bilangan entiti

Jadual 1.0 : Anggaran ruang storan

Jenis Jadual Yang Dibentuk Jumlah Storan (Bait)


Jadual Bangunan 3033
Jadual Pili Bomba 685
Jadual Jalan 395
Jadual Parit 1
FASA PEMBANGUNAN PANGKALAN
DATA

 Memasukkan data spatial


 Menyimpan data
 Pemprosesan Geografi (Geoprocessing)
 Memasukkan data atribut
 Memaparkan maklumat
 Mengurus sistem
 Menyelenggaraan sistem
DATA SPATIAL

 Kemasukan data melalui :


 Papan kekunci;
 Pengimbasan;
 Pertukaran format fail.

 Geoprocessing yang telah dijalankan :


 “Pembersihan” data input;
 Pembinaan topologi;
 Menjalankan projection;
 Pembersihan topologi;
 Percantuman peta.
DATA ATRIBUT

 Kemasukan data melalui


 Papan kekunci
 Pertukaran format fail
Physical Database
cont……
Example
Here’s an example of a chart showing the relationships between
flat files in a sample relational database for food suppliers* in
Microsoft Access

* This comes from an MS ACCESS sample database


* This comes from an MS ACCESS sample database
SQL (Structured Query
Language)
 A database access language used in querying,
updating, and managing relational databases.
 SQL has a common core that, generally, is available
in all product implementations of the language.
 It has become a de facto standard because it is
widely used and recognized by the industry as being
standard.
Structured Query Language
(SQL)
 SQL is used to communicate with a database. It was developed
to facilitate the querying of relational databases.
 SQL statements are used to perform tasks such as update data
in a database, or retrieve data from a database.
 Advantages
– simplicity
– English-like style
– wide application
Relational Operators

 Frequently • equal to ( = )

used for • greater than ( > )


attribute data
query • less than ( < )

• greater than or equal to ( >= )

• less than or equal to ( <= )

• not equal to ( != )
Boolean Operators
Connectors

 And
 Or
 Not
 Xor (Exclusive Or)

(Heywood et al., 1998)


GIS Query

 Aspatial
– questions about the attributes of features
– can be performed by database software alone
 prompts and query builder
 Spatial
– answers the question, “Where is something?”
– associated with location; distances, areas,
perimeters
– usually presented in map form; computer screen
SQL: Example
 Here is a simple query that displays data from
Table1:
– SELECT Table1.[First Name], Table1.[Last Name]
– FROM Table1
– ORDER BY Table1.[First Name];
 This will generate a query that shows the fields First
Name and Last Name from Table1, ordering them
by the First Name.
SQL Continued
 This language can get quite complicated:
– SELECT DISTINCTROW
Customers.CustomerID,
Customers.CompanyName, Customers.City,
Customers.Country
– FROM Customers RIGHT JOIN Orders ON
Customers.CustomerID = Orders.CustomerID
– WHERE (((Orders.OrderDate) Between
#1/1/95# And #12/31/95#));

S-ar putea să vă placă și