Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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
Multimedia databases
Database
Database
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
Sharing a database
Allow multiple users and programs to
access the database simultaneously
System protection
Security protection
An Example
UNIVERSITY database
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
An Example (cont'd.)
Construct UNIVERSITY database
An Example (cont'd.)
Examples of queries:
An Example (cont'd.)
Examples of updates:
An Example (cont'd.)
Phases for designing a database:
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
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
Data model
Multiuser DBMS
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
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.
Data normalization
Denormalization
Sometimes necessary to use controlled
redundancy to improve the performance of queries
Indexes
Buffering and caching
Query processing and optimization
Business rules
Inherent rules of the data model
Trigger
Rule activated by updates to the table
Stored procedures
More involved procedures to enforce rules
Application programmers
Tool developers