Database Management System (DBMS)

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 45

MODULE 1

Database Management System (DBMS)


Overview
Overview

 Why we need database

 Database Concept

 Types of database models

 Relational database
DBMS
• DBMS is a collection of data
(database) and programs to access
that data. The goal of DBMS is to
store, retrieve, and display
information
• Key characteristics of DBMS are:
performance, store large volume of
database, share data (access),
provide security (authorization),
remove redundancy (normalization)
and provide concurrent access
(different users at the same time).
Why we need database?

 Without database GIS is cartography

(electronic map)

 No database No spatial analysis


Why we need database?

Principles of GIS

Information Hardware

GIS

People Software
Database and GIS
GIS database

Attribute Spatial data


DBMS location

Text, Images
Sound, movie
Multimedia
Data abstraction

• Physical level: Describe how the


data are actually store (word or
bytes)

• Conceptual level: Describe what


data are actually stored in the
database (Structure). it gives
Schematic representation of
phenomena
Data abstraction-Continue

• View level: Describe only a part of the


entire database. Many users of the database
may be concerned with a subset of
information. The system may provide many
views for the same database
Data abstraction

Different users for


the same database
View Level

Conceptual level

Logical Level
Instance of schemes

• The collection of database at a particular


moment is called the instance of the
database
• The overall design of the database is called
the database scheme
Types of database models

Data model is a collection of


conceptual tools for describing data,
data relationship, data semantics, and
consistency constraints. There are
mainly three types of models

• Object-based logical models


Are used to describe data at the
conceptual and view level. Example
of these the Entity-Relationship
model and object-oriented model
Data models- Continue

• Record-based logical models


Are used to describe data at the conceptual and
view level. Example of these are: Network
model, Hierarchical model, and relational model.

• Physical data models


Are used to describe data at the physical level
(bytes and words). It is mainly deal with
hardware.
Entity-Relationship (E-R) model

• It is based on simulation of the real world


which consists of basic objects called
entities and relationship among these
objects
• The overall logical data structure of a
database can be expressed graphically by
an E-R diagram. Which consists of
rectangle (entity), ellipse (attribute),
diamond(relationship), and lines.
Object oriented Model

The basic unit that an object-oriented (OO-


DBMS) manages is the object. It is based on
four basic concepts of abstraction:
• Classification: Mapping of several objects
(instances) to common class
• Generalization: Group several classes which
have the same properties in common (roads,
railway)-transportation network
Object oriented Model-Continue

• Association: Relation between similar


objects is considered a higher level set
object
• Aggregation: Objects which consist of
several other objects (Composed objects)
Object oriented Model-Continue
• OO model uses objects rather than records to manage data
• An object is a collection of data elements and operations
that together are considered a single entity
• An object has associated with it a set of variables that
contain the data for the object, a set of messages to which
the object respond, and a method which response to the
message
Object Oriented Model-Continue
• Once the structure is setup, the details of it
need not be user visible
• This approach has the attraction that query is
very natural
• A geographic data handling systems employ
this model are:
TIGRIS, DAPLEX, and PROBE
• It is application in GIS is recommended
Object oriented Model-Continue

• Objects are typed and the format and


operations of an object instance are the same
as some object prototype
• Example of an object might be a lake:
• List of border chain: C1, C2, C3, Cn
• List of nodes: N1, N2, N3, Nn
• Attribute: Depth, soil type
Hierarchical Model
• Based on Tree structure (child-parent)
• No element can have more than one parent
• Requires knowledge by the user of the
actual storage scheme used by the DBMS
• Examples of database are:
System2000 and IMS
• Not commonly applicable in GIS
Network Model
• Organized data in a network or plex
structure (child-parent)
• Children may have more than one parent
• The query language is procedural
• Examples of database are:
DBMS-10, DMS1100, IDMS
• Not commonly applicable in GIS
Database tree structure (Hierarchical, Network)

Root (Parent)
A1
Child
B1 B2 Parent

C1 C2 C3
C4 C5 C6
Child
Child
Relational model
• A relational database consists of a collection of
tables, each of which is assigned a unique name
• The relational models differs from network and
hierarchical models in that it does not use
pointers or links. Instead , the relational model
relate records by the value they contain.This
freedom from the use of pointers allows formal
mathematical foundation to be defined
• Examples of RDBMS are Oracle, Informix, and
Sybase
Reasons to use Relational Model
• Independence of the physical data storage and logical
database structure. Results in users do not need to
understand the underlying physical layout of the data
to access data from a logical structure, such as a table
• Variable and easy access to all data. Results in access
to data is not predefined as in hierarchical databases
in which users must understand and navigate through
the hierarchy to retrieve data
• Flexible in database design. i.e complex objects are
expressed as simple tables and relationships
• Applying relational design methods reduces data
redundancy (Normalization) and storage requirements
Relational DBMS
• Aspects of an RDBMS

– Structures: Well defined objects


– Operations: Clearly defined actions
– Integrity Rules: Rules that control which
operations are allowed on the data and
structures of the database
Relational DBMS

• Components of a Relational Database


– Table: collection of rows all containing the same
columns
– Row: Horizontal components of a table. Consists
of values for each column. Each row is
equivalent to a record
– Column: Vertical component of a table. Each
column in the record is often referred to as a field
Relational DBMS
• Relational Database Rules
– Each column in a table must be unique
– The order of the rows in a table is not meaningful
– The order of the columns in a table is not
meaningful
– All data in a column must be the same type
– Every table has a primary key, each column in the
primary key must have a value
Relational DBMS

• Primary Key and Foreign Key


– Relational database use primary keys and foreign
keys to allow mapping of information from one
table to another
– A foreign key is column or group of columns in a
table whose value matches those of the primary
key of another table
– Values in primary key column must be unique
e.g. social security number (SSN)
Relational DBMS

• Primary Key and Foreign Key


– Referential Integrity refers to the integrity of
the reference from the primary key in one table
to a foreign key in another table.
Relationships between Tables

• One-to-One
• One-to-Many
• Many-to-One
• Many-to-Many
Relational DBMS
• Relational Database Example (1-1)

Weather table
city_name measurement_dt avg_temp
Washington 05-01-94 70
Amsterdam 05-01-94 47 Location table
Warsaw 05-01-94 43 city_name country_name
Tokyo 05-01-94 60 Seattle United States
Washington 05-01-94 55 Amsterdam Neatherlands
Warsaw Poland
Tokyo Japan
Washington 05-01-94
Foreign Key Primary Key
Primary Key
One-to-One
NAME AREA POP1990 NAME POP1997
Caroline 331.8066 27035 Caroline 29424
Talbot 238.2847 30549 Talbot 32565
Dorchester 534.1747 30236 Dorchester 29953
Wicomico 383.3481 74339 Wicomico 79716
Worcester 457.6503 35028 Worcester 41885
Somerset 269.267 23440 Somerset 24251

NAME AREA POP1990 POP1997


Caroline 331.8066 27035 29424
Talbot 238.2847 30549 32565
Dorchester 534.1747 30236 29953
Wicomico 383.3481 74339 79716
Worcester 457.6503 35028 41885
Somerset 269.267 23440 24251
Relational DBMS

• Relational Database Example (1-M)

Complexes table
comp_name N.Shops N.Banks
Kotraya 444 70
H.Plaza 555 47 Owner table
Komtar 622 43 comp_name shop_owner
Kotraya ALi
Kotraya Tan
Kotraya Lee
Primary Key Kotraya Raman
Kotraya Nora

Foreign Key
One-to-Many
Dept. Advisor Advisor Name
Agri Shorter Shorter Aaron
Agri Mollett Ruby Brian
Nat Sci Ruby Mollett Devin
Shorter Eric
Shorter Julie
Ruby Leigh
Dept. Advisor Name Mollett Ronnie
Agri Shorter Aaron Mollett Ryan
Nat Sci Ruby Brian
Agri Mollett Devin
Agri Shorter Eric
Agri Shorter Julie
Nat Sci Ruby Leigh
Agri Mollett Ronnie
Agri Mollett Ryan
Many-to-One

SITE AREA Veg Type Veg Type Name Dominant pH of Soil


WV1 331.8066 D1 C2 Forest Coniferous Scrub Pine 6.5
WV2 238.2847 C2 D1 Forest Deciduous Maple 8
MD1 534.1747 D1 S3 Wetland Swamp Skunk Cabbage 5
MD2 383.3481 S3

SITE AREA Veg Type Name Dominant pH of Soil


WV1 331.8066 D1 Forest Deciduous Maple 8
WV2 238.2847 C2 Forest Coniferous Scrub Pine 6.5
MD1 534.1747 D1 Forest Deciduous Maple 8
MD2 383.3481 S3 Wetland Sw am p Skunk Cabbage 5
Data Definition Language (DDL)
and Data Manipulation Language (DML)

• DDL store files that contains data about


data (metadata). For example storage of
structure in data dictionary
• DML enable users to access or manipulate
data (retrieval, insertion, deletion). The part
of DML that involves information retrieval
is called a query language (QL)
Types of DML

• There are two types of DML, procedural and


non procedural
• Procedural DML: Require the user to specify
what data is needed and how to get it
• Non-procedural DML: Require the user to
specify what data is needed without specify
how to get it
Query language (QL)

• QL is the language in which a user requests


information from the database. Example of
QL are relational algebra (procedural) and
tuple relational calculus (nonprocedural)
• The most common query languages are
Structured Query Language (SQL),Query
By Example (QBE), and Quel
• SQL has gain wide acceptance in
commercial products
Relational algebra (RA)

• RA is a procedural query language. It


consists of a set of operations that take one
or two relations as input and produce a new
relation as a result
• The fundamental operations in RA are
select(6), project(II), Cartesian product(X) ,
rename, union(U), and set difference(-)
• Other operations include intersection,
natural join, division, and assignment
Structured Query Language (SQL)
• SQL is the standard relational database
language
• SQL include commands not only restricted to
query but to other functions such as defining
relation, deleting relations, creating indices,
and modifying relation scheme, access right,
integrity, and transaction control
• Basic structure of an SQL expression consists
of three clauses: Select, from, and where
• A typical SQL query has the form
select A1, A2, ..., An
from r1, r2, .., rm
where P
Each Ai represents an attribute and each ri a
relation. P is a predicate (selection). The list
of attributes A1..An can be replaced by (*)
to select all attributes
• The result of an SQL query is a relation
(table)
• The keyword “distinct” is used after select to
force the elimination of duplicates. For
example, find all customer names having a
balance equal $ 6000
select distinct customer-name from
AccCust where balance = 6000
• SQL supports union, intersect, and minus
• SQL uses logical connectives and, or, and
not and operators (+, -, *, /) on values from
tuples
e.g.
select distinct customer-name
from AccCust
where balance between 600 and 700
Exporting and Importing Data

• Export and Import utilities allows data to be


moved in and out of the native database.
For Example, converting database tables to
other format such Comma Delimited
Format (CDF), Space Delimited Format
(SDF), *.dbf, and ASCII flat files (Text)
Relational Database design

In the database design considerations must be paid to:


• Repetition of information (Normalization)
• Loss of information
• Number of fields and records required, some
RDBMS supports limited number of fields and
records (e.g. 255 fields)
• Nature of database, some RDMBS supports only
textual data, some supports multimedia (sound,
image, etc.)
Database quality

Check accuracy of attribute database by


Performing quality assurance / quality
control (QA/QC) on the database by:

• Check correctness of data


• Check mis-typing errors

You might also like