Sistem Basis Data
Djoko Pramono
What is Database
Daily activities will involve aplication to access database
What is Database
What is Database
What is Database
Overview
Traditional database applications
Store textual or numeric information
Multimedia databases
Store images, audio clips, and video streams
digitally
Geographic information systems (GIS)
Store and analyze maps, weather data, and
satellite images
Data warehouses and online analytical
processing (OLAP) systems
Extract and analyze useful business
information from very large databases
Support decision making
Real-time and active database
technology
Control industrial and manufacturing processes
Database
Database
Collection of related data
Known facts that can be recorded and that have
implicit meaning
Miniworld or universe of discourse (UoD)
Represents some aspect of the real world
Logically coherent collection of data with
inherent meaning
Designed, Built and Populated for a specific
purpose
Database
Typically describing the activities of one
or more related organization
Example : University
Entities : student, faculty, courses,
classroom
Relationship : student
enrollmentincourses, the use of room
for courses
Database management system
(DBMS)
Database management system (DBMS)
Collection of interrelated data and a set of
programs to access those data
Collection of programs that enables users to
create and maintain a database.
A software system designed to store,
manage, and facilitate access to databases.
Database management system
(DBMS)
Defining a database
Specify the data types, structures, and
constraints of the data to be stored
Database Meta-data
Database definition or descriptive
information
Stored by the DBMS in the form of a
database catalog or dictionary
Database management system
(DBMS)
Manipulating a database
Query to retrieve data
update the database
Generate reports
Sharing a database
Allow multiple users and programs to
access the database simultaneously
Database management system
(DBMS)
Application program
Accesses database by sending queries to
DBMS
Query Causes some data to be retrieved
Transaction may cause some data to be
read and some data to be written into the
database
Database management system
(DBMS)
Protection includes:
System protection
Security protection
Maintain the database system
Allow the system to evolve as requirements
change over time
An Example
UNIVERSITY database
Information concerning students, courses, and
grades in a university environment
Data records
STUDENT
COURSE
SECTION
GRADE_REPORT
PREREQUISITE
An Example (cont'd.)
Specify structure of records of each file by
specifying data type for each data
element
String of alphabetic characters
Integer
Etc.
An Example (cont'd.)
Construct UNIVERSITY database
Store data to represent each student, course,
section, grade report, and prerequisite as a
record in appropriate file
Relationships among the records
Manipulation involves querying and
updating
An Example (cont'd.)
Examples of queries:
Retrieve the transcript
List the names of students who took the
section of the Database course offered in fall
2008 and their grades in that section
List the prerequisites of the Database course
An Example (cont'd.)
Examples of updates:
Change the class of Smith to sophomore
Create a new section for the Database course
for this semester
Enter a grade of A for Smith in the Database
section of last semester
An Example (cont'd.)
Phases for designing a database:
Requirements specification and analysis
Conceptual design
Logical design
Physical design
Characteristics of the Database
Approach (cont'd.)
Main characteristics of database approach
Self-describing nature of a database system
Insulation between programs and data, and
data abstraction
Support of multiple views of the data
Sharing of data and multiuser transaction
processing
Self-Describing Nature of a
Database System
Database catalog contains complete definition of
structure and constraints
Meta-data : Describes structure of the database
Database Catalog used by:
DBMS software
Database users who need information about database
structure
In traditional file processing, data definition is typically
part of the application programs themselves, structure is
declared in the application programs. C++ may have
struct or class declarations
Insulation Between Programs
and Data
Program-data independence
RDBMS : Structure of data files is stored in
DBMS catalog separately from access
programs
Traditional file processing : structure of data
files is embedded in aplication program.
changes to the structure of a file may require
changing all programs that access that file
Program-operation independence
Operations in object oriented and object
relational system, specified in two parts:
Interface includes operation name and data types of
its arguments
Implementation can be changed without affecting
the interface
Data Abstraction
Data abstraction
Allows program-data independence and
program-operation independence
Conceptual representation of data
Does not include details of how data is stored
or how operations are implemented
Data model
Type of data abstraction used to provide
conceptual representation
Support of Multiple Views of the
Data
View
Subset of the database
Contains virtual data derived from the
database files but is not explicitly stored
Multiuser DBMS
Users have a variety of distinct applications
Must provide facilities for defining multiple
views
Data Model
A data model is a collection of high level concepts
for describing data.
A schema is a description of a particular collection
of data, using the a given data model.
The relational data model is the most widely used
model today.
Main concept: relation, basically a table with
rows and columns.
Every relation has a schema, which describes the
columns, or fields.
schema
Students( sid: string, name: string, login:
string, age: integer, gpa: real)
schema says that each record in the
Students relation has five fields, with field
names and types as indicated.
Each row in the Students relation is a
record that describes a student.
Levels of Abstraction
External Schema
External Schema
Conceptual Schema
Physical Schema
DISK
External Schema
Physical Schema
Physical Schema describe the files and
indexes used
Specifies index to speed up data retrieval
operation.
Decisions about the physical schema are
based on an understanding of how the
data is typically accessed.
conceptual schema
conceptual schema describes the stored data
in terms of the data model of the DBMS
describes all relations that are stored in the
database
Example :
Students( sid: string, name: string, login:
string,age: integer, gpa: real)
Faculty (fid: string, fname: string, sal: real)
Courses( cid: string, cname: string, credits:
integer)
External schema(View)
Each external schema consists of a
collection of one or more views and
relations from the conceptual schema
A view is conceptually a relation, but the
records in a view are not stored in the
DBMS
The external schema design is guided by
end user requirements
Sharing of Data and Multiuser
Transaction Processing
Allow multiple users to access the
database at the same time
Concurrency control software
Ensure that several users trying to update the
same data do so in a controlled manner
Result of the updates is correct
Online transaction processing (OLTP)
application
Sharing of Data and Multiuser
Transaction Processing (cont'd.)
Transaction
Central to many database applications
Executing program or process that includes one
or more database
Isolation property
Each transaction appears to execute in isolation from
other transactions
Atomicity property
Either all the database operations in a transaction
are executed or none are
Transaction
Transaction : single logical operation on
the database.
A Transaction may involve several
actions.
For example, a transfer of funds from one
bank account to another, even involving
multiple changes such as debiting one
account and crediting another, is a single
transaction.
ACID
Atomicity : each transaction be "all or
nothing": if one part of the transaction
fails, then the entire transaction fails, and
the database state is left unchanged.
Write Ahead Log, Before a change is
made to the database, the
corresponding log entry is forced to a
safe location(disk).
ACID
Consistency : any transaction will bring
the database from one valid state to
another. Any data written to the database
must be valid according to all defined
rules, including constraints, cascades,
triggers, and any combination.
ACID
Isolation : ensures that the concurrent
execution of transactions results in a
system state that would be obtained if
transactions were executed serially, i.e.,
one after the other.
Shared Lock : An object can be held by
two transaction.
Exclusive Lock : An object can be held
by onky one transaction.
ACID
Durability : ensures that once a
transaction has been committed, it will
remain so, even in the event of power
loss, crashes, or errors.
Disadvantages of Using file
system
Data redundancy and inconsistency.
Different programmer create various file are likely
have different format, same information may
duplicated
Difficulty in accessing data. Conventional
file-processing environments do not allow needed
data to be retrieved in a convenient and efficient
manner. More responsive data-retrieval systems
are required for general use
Disadvantages of Using file
system
Data isolation. Data scattered in various file,
write program to retrieve data is difficult.
Integrity problem. Data values in database
must satisfy some consistency constraints. when new
constraints are added, it is difficult to change the
programs to enforce them. The problem is compounded
when constraints involve several data items from
different files
Disadvantages of Using file
system
Atomicity problem. No transactional in file
system.
Concurrent access anomalies. Not support
multiple user access in same time.
Security problems. No role based access
control.
Advantages of Using the DBMS
Approach
Controlling redundancy
Data normalization
Denormalization
Sometimes necessary to use controlled
redundancy to improve the performance of queries
Restricting unauthorized access
Security and authorization subsystem
Privileged software
Advantages of Using the DBMS
Approach
Providing persistent storage for program
objects
Complex object in C++ can be stored
permanently in an object-oriented DBMS
Impedance mismatch problem
Object-oriented database systems typically offer
data structure compatibility
Advantages of Using the DBMS
Approach
Providing storage structures and search
techniques for efficient query processing
Indexes
Buffering and caching
Query processing and optimization
Advantages of Using the DBMS
Approach
Providing backup and recovery
Backup and recovery subsystem of the
DBMS is responsible for recovery
Providing multiple user interfaces
Graphical user interfaces (GUIs)
Representing complex relationships among
data
May include numerous varieties of data that
are interrelated in many ways
Advantages of Using the DBMS
Approach
Enforcing integrity constraints
Referential integrity constraint
Every section record must be related to a course
record
Key or uniqueness constraint
Every course record must have a unique value for
Course_number
Business rules
Inherent rules of the data model
Advantages of Using the DBMS
Approach
Permitting inferencing and actions using
rules
Deductive database systems
Provide capabilities for defining deduction rules
Inferencing new information from the stored
database facts
Trigger
Rule activated by updates to the table
Stored procedures
More involved procedures to enforce rules
Advantages of Using the DBMS
Approach
Additional implications of using the
database approach
Reduced application development time
Flexibility
Availability of up-to-date information
Economies of scale
Actors on the Scene
Database administrators (DBA) are
responsible for:
Authorizing access to the database
Coordinating and monitoring its use
Acquiring software and hardware resources
Database designers are responsible for:
Identifying the data to be stored
Choosing appropriate structures to represent
and store this data
Actors on the Scene (cont'd.)
End users
People whose jobs require access to the
database
Types
Casual end users
Naive or parametric end users
Sophisticated end users
Standalone users
Actors on the Scene (cont'd.)
System analysts
Determine requirements of end users
Application programmers
Implement these specifications as programs
Workers behind the Scene
DBMS system designers and implementers
Design and implement the DBMS modules and
interfaces as a software package
Tool developers
Design and implement tools
Operators and maintenance personnel
Responsible for running and maintenance of
hardware and software environment for database
system
A Brief History of Database
Applications
Early database applications using
hierarchical and network systems
Large numbers of records of similar structure
Providing data abstraction and application
flexibility with relational databases
Separates physical storage of data from its
conceptual representation
Provides a mathematical foundation for data
representation and querying
A Brief History of Database
Applications (cont'd.)
Object-oriented applications and the need for
more complex databases
Used in specialized applications: engineering
design, multimedia publishing, and manufacturing
systems
Interchanging data on the Web for ecommerce using XML
Extended markup language (XML) primary
standard for interchanging data among various
types of databases and Web pages
A Brief History of Database
Applications (cont'd.)
Extending database capabilities for new
applications. Extensions to better support
specialized requirements for applications:
1)Scientific applications that store large amounts of
data
2)Storage and retrieval of images, video
3)Data mining
4)Spatial applications that store spatial locations of
data, geographical information systems
5)Time series
Databases versus information retrieval
Information retrieval (IR)
Deals with books, manuscripts, and
various forms of library-based articles
Data is indexed, cataloged, and
annotated using keywords. IR is
concerned with searching for material
based on these keywords, and with the
many problems dealing with document
processing and free-form text processing
When Not to Use a DBMS
More desirable to use regular files for:
Simple, well-defined database applications not
expected to change at all
Stringent, real-time requirements that may not
be met because of DBMS overhead
No multiple-user access to data
Embedded systems with limited storage
capacity