0% found this document useful (0 votes)
3 views43 pages

3 DBMS

This document provides an overview of Database Management Systems (DBMS), detailing their purpose, structure, and functionalities. It explains key concepts such as databases, data models, relational data models, and the importance of integrity constraints in database design. Additionally, it covers querying techniques and the role of SQL in data extraction and manipulation.

Uploaded by

globallandmark11
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)
3 views43 pages

3 DBMS

This document provides an overview of Database Management Systems (DBMS), detailing their purpose, structure, and functionalities. It explains key concepts such as databases, data models, relational data models, and the importance of integrity constraints in database design. Additionally, it covers querying techniques and the role of SQL in data extraction and manipulation.

Uploaded by

globallandmark11
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/ 43

Geographic Information Systems I

Database management systems-recap


Ir. Aphrodis Nzabandora
Database Management Systems

• Contents:
– Databases: what and why ?
– Using a DBMS
– The relational data model
– Querying a relational database
– GIS databases
Data, Dataset, Database, DBMS and DB System

• Data
– Is a resource held on paper or in digital format that
serves to record or administer some facts and
description of phenomena of interest.
• Data set (or dataset):
– A homogeneous collection of data normally
describing a single kind of phenomenon
Databases: what and why ?
What is a database ?
• Database
– A collection of interrelated data sets properly
structured by means of, and stored through a DBMS.
(A file containing datasets)
– A collection of inter-related data stored together to
serve one or more applications
– A combination of software and hardware that
makes it possible and convenient to perform tasks
that involve handling large amounts of data
– Textbook : a large, computerized collection of
structured data
Databases: what and why ?
Why use a database ?

– handling large amounts of data

– establishing complex relationships between data

– enabling multiple users to share data

– reducing duplicate data, minimising redundancy

– avoiding data loss


If not ……better use a flat file system (M. Excel)
Databases: what and why ?
Databases: what and why ?

• Database characteristics

–Applications oriented
–Data sharing
–Minimum redundancy
–Data integrity
–Secure and reliable
–Database management system -DBMS
Database management system (DBMS), Database
system
• Database management system (DBMS)
A software package that is designed for the purpose of
managing databases. This means, DBMS allows to set-
up, maintain and exploit one or more databases.

• Database system
 Combination of a database and its DBMS.
Using a DBMS
A DBMS consists of a set of programs that provide
facilities to set up, use and maintain a database.

– handling of large data sets


– maintain data correctness (integrity constraints)
– Support concurrent use of data (i.e. data sharing)
– provide a query language
– the use of a data model
– Enable data backup and recovery
– control of data redundancy
Terminology
Data Model

• A DBMS supports the use of a data model.

• Data model is an integrated collection of:


– Data structuring primitives,
– Rules of how to structure, and
– Mechanisms to handle the data in a database.

• In other words, a data model is a toolbox that allows us


to create/define a database structure and manipulate the
data stored in it.
Using a DBMS
Examples of relational DBMS

– bottom line: PC-file, Cardbox, Cardfile


– middle category: MS-Access, FoxPro, Paradox,
dBASE
– top end: Oracle, Ingres, Sybase, Informix
Relational data Model
Why Study Relational data Model?

• The introduction of relational data model (by Ted Codd


in 1970) is considered as the most important event in
the history of the database field.

• It is based on predicate logic and set theory.

• It is based on simple and uniform data structure (the


relation).
Terminology
Relational data model
The relational data model is an integrated collection of:

1. Data structuring primitives = attributes, tuples, and


relations,
2. Rules of how to structure = data definition language, and
3. Mechanisms to handle the data in a database = data
manipulation language.
Terminology
The language used in relational data model
• Structured Query Language (SQL) – the relational database
language:
– ISO standard (from 1987)

– Powerful and natural language based on relational


calculus (specific version of predicate logic and set
theory)
– Example:
Which countries produced potatoes last year?
• SELECT DISTINCT c.CNAME
• FROM Countries AS c, Productions AS p
• WHERE c.ID=p.cid AND p.crop=“Potatoes" AND
p.annum=2009 AND p.score>0
Terminology
Domain

• Domain
– A set of atomic values – e.g.: the domain of the real
numbers, the domain of the dates, the domain of
character strings with maximal length 10…

• In database technology, a domain is simply a data type:


– a system-defined type, e.g.: INTEGER, CHAR, VARCHAR, DATE/TIME . .
.
Terminology
Attribute
• Attribute
– In the relational data model, we represent real-world
objects by tuples stored in relations (tables).
– Each object in the real world has particular properties,
i.e., attributes that describe it.
– The relation Productions has these attributes: cid, crop,
annum, score, quality
Terminology
Attribute & Domain

• Each attribute has an associated domain:


– In Productions relation:
• cid: integer, crop: varchar(255), annum: integer, score:
integer and quality: varchar(255)
Terminology
Tuple

• In the relational data model, we represent real-world


objects by tuples stored in relations (tables).
• Tuple can be viewed as:
– a list of attribute values
– One tuple from Productions relation is:
• (cid=3, crop=“Rice,paddy”, annum=2000, score=300,
quality=“F”)
Terminology
Relation
• Relation always consists of two parts:
– Relation schema – a bracketed list of attributes with
their domains (e.g. Productions (cid: integer, crop:
varchar(255), annum: integer, score: integer, quality:
varchar(5)),

• Relation instance – a set of tuples.

on 18.10.2010 – 15:47 relation Productions had five attributes and 6930 tuples
Terminology
Relation

• Relation, Tuple, Attribute in Productions relation in


FAOcrops.mdb
Terminology
Relational Database
• Relational database
A collection of relations, where each relation
stores facts of a certain type.
• A database schema:
A collection of relation schemas (with no
duplicate relation names) – e.g.: FAOcrop
(Productions, Yields, Countries, Population)
Terminology
Process of database design

• Relational database design involves:


– Deciding which relations will be present in the database,
and
– Defining their schemas, which involves:
• Deciding which attributes relations will have, and
• What are the domains of these attributes.

• But database design also includes:


– Defining relationships between relations by integrity
constraints, and
– Defining queries and update operations (transactions).
Constraint
What are integrity constraints?

• A (static) integrity constraint is a rule that the database


instance must obey at all times!
• Two integrity constraint taxonomies are useful:
– Based on support level by the DBMS – implicit, user-
defined.

– Based on data structure granularity – attribute, tuple,


relation, database constraints.
Terminology
Relational data model

3 golden rules of data integrity

1: Key uniqueness: the key value of any tuple (record) in


any relation (table) must be unique
2: Key Integrity: There are no ‘unknowns’ in any tuple
(record)
3: Referential Integrity: The foreign key value is either
blank (for all its attributes) or it is the key value of an
existing tuple (record) in the relation (table) the foreign
key refers to.
Keys
Primary Key

• The key of a relation R is a set K of R‟s attributes, such


that:

– It is unique – there are no two distinct tuples of K that


have the same attribute values.
– It is minimal – there is no proper subset of K that is
unique.

• If there is more than one key for R, the database designer


chooses one of them to become the primary key. The
other remain candidate keys.
Keys
Primary Key

• Example – Countries
table in
FAOcrops.mdb
– Two candidate keys:
ID, CNAME

– One, ID, is chosen as


primary key – reason:
ID is a better
reference, because its
values are less likely to
change.
Keys
Primary & Candidate key
Keys
Referential integrity
• A foreign key is a set of attributes that is used to refer to
a tuple in another relation.
• It must correspond with a primary key value in the
second relation.
 A foreign key behaves like a ‟logical pointer‟.
Data Retrieval
Lecture Overview

Terminology overview
First principles of data extraction:
Tuple selection
Attribute projection
Tuple selection & attribute projection
Table joining
Terminology
Data extraction, Query and Transaction

• Data extraction
The process of acquiring from a data set precisely that data
that is required/wanted/needed.
• Query
Precisely formulated request to extract data from the
database.
• Transaction
Precisely formulated request to make changes to data in the
database (may include data extraction).

• Query and Transaction can be viewed as a high-level


computer program.
Querying the database
How to..?
Before we query the database
Querying the database
Simple method of query definition

Steps:
1. INPUT RELATION
• On which relation is the query based?
• What will be the tuple variable?
2. SELECTION CONDITION
• What is the condition that the selected tuple for the output
must fulfill?
3. OUTPUT RELATION
• What are the attributes in the output?
Querying the database
How to..?
Querying the database
Tuple selection example
Querying the database
Tuple selection example
Terminology
Tuple selection

• Tuple selection is the retrieval of the tuples specified by


a given condition.
• We are selecting a subset of the data present.

Observe that some tuples in the input are selected and others are left out.
Querying the database
Attribute projection example
Querying the database
Attribute projection example
Querying the database
Attribute projection example
Terminology
Attribute projection

• Attribute projection is the retrieval of indicated attributes


from all tuples in the relation.

We are ‘projecting on’ attributes 1 and 3.


Querying the database
Tuple selection & attribute projection then Join

• The join condition for this example is


• TitleDeed.Plot = ParcelPid, which expresses a foreign
key/key link between TitleDeed and Parcel.
• The result relation has 3 + 3 = 6 attributes.
Querying the database
Tuple selection & attribute projection :Combined
selection/projection/join query

• The join is done first,


then follows a tuple
selection on the
resulting tuples of
the join, which is
completed by an
attribute projection.
Thanks for your attention

You might also like