Sie sind auf Seite 1von 30

Advanced Database Systems

Database

A database can be defined as an organized collection of non-redundant data which can be shared by different application systems , typically describing the activities of one or more organizations.

Database Management Systems

Software designed to assist in maintaining and utilizing large collections of data. Collection of interrelated files and set of programs that allow users to access and modify these files.

Files v/s DBMS


Data redundancy and inconsistency Difficulty in accessing data Data isolation Integrity problems Atomicity problems Concurrent access anomalies Security problems

Advantages of DBMS

Centralized data management

Data administration Sophisticated techniques for storage and retrieval Data types Check on bounds Uniqueness on data items Restricting unauthorized access

Efficient data access

Data integrity (enforcing integrity constraints)


Security

Controlling data redundancy Data independence

Flexibility, abstract view of data, no details of storage Feeling as one user access at a time Effects of system failures Quick application development time

Concurrent access

Crash recovery

Reduced application development time

DBMS components

Data: numerical data, non-numerical data and complicated data entities such as pictures and images Data definition language (DDL): used to describe the contents of the database- attribute names , data types, location in the database, etc. Data manipulation and query language: commands for input, edit, analysis, output, reformatting, etc. SQL - Structured Query Language.

Programming tools: accessibility directly from

application programs through function calls (subroutine calls) in conventional programming languages.

Data Model

Collection of high level data description constructs that hide many low-level storage details.

Examples of data models


Relational data model Oracle, Sybase,DB2, Informix, Access, Foxbase, Tandem, Teradata, MySQL Hierarchical data model IMS DBMS Network data model IDS, IDMS Object Oriented data model
Objectstore, versant

Object Relational data model

Oracle, Informix, Versant, ObjectStore

Semantic Data Model

More abstract, high level data model helps users to come up with a good initial design contains wide variety of constructs that help describe a real application scenario Semantic model design subsequently translated into a data model

Eg Relational model The data description model used is the relation or a set of records.

A description of data in terms of a data model is the schema. Students (sid:string,name:string,login:string,age:integer,gpa:re al)

User/programmer Database System Application Programs/Queries

DBMS s/w

Software to process Queries/programs

Software to access stored data

Stored DB Defn

Stored DB

Simplified database system environment

Levels of Abstraction in DBMS

Schema : Description of data in terms of a data model Schema of a relation in Relational model
Students(sid:string,name:string,login:string, age:integer)

Relational model of data Main concept: relation, basically a table with rows and columns. Every relation has a schema, which describes the columns, or fields.

Levels of Abstraction in DBMS


View 1 View 2 View 3

Conceptual Schema

Physical Schema

Disk

Conceptual Schema

Logical Schema Describes the stored data in terms of the data model of the DBMS Process of arriving at a good conceptual design is called conceptual database design Eg University Database

Physical Schema

Specifies additional storage details w.r.t. secondary storage devices Physical schema describes the files and indexes used.

Indexes : auxiliary data structures used to speed up data retrieval operations

External Schema

Views conceptually a relation (without storage) Describe how the user sees the data Allow Data access to be customized and authorized at the level of individual users or groups of users Several external schemas possible for a database Collection of one or more relation

Example: University Database


Conceptual schema: Students(sid: string, name: string, login: string, age: integer) Courses(cid: string, cname:string, credits:integer) Enrolled(sid:string, cid:string, grade:string)

Physical schema: Relations stored as unordered files. Index on first column of Students.

External Schema (View): Course_info(cid:string,enrollment:integer)

Data Independence

Applications insulated from how data is structured and stored. Achieved using the 3 levels of abstraction. Logical data independence: Protection from changes in logical structure of data. Physical data independence: Protection from changes in physical structure of data.

Transaction Management

Transaction: An Execution of a DB Program Key concept is transaction, which is an atomic sequence of database actions (reads/writes). Each transaction, executed completely, must leave the DB in a consistent state if DB is consistent when the transaction begins.

Concurrent Execution of Transactions

Concurrent data access

Reservation Systems / Banking

Concurrent execution of user programs is essential for good DBMS performance. Actions of various users are interleaved by DBMS in such a way that they do not interfere with each other Users are given the feel of using a singleuser system.

Scheduling Concurrent Transactions


Locking Protocol (set of rules) Ensures that concurrent execution of {T1, ... , Tn} is equivalent to some serial execution T1 ... Tn using some locking protocol Lock mechanism to control access to database objects

Two types of locks

Exclusive lock - can be held by one and only one transaction at a time Shared lock - can be held by many different transactions at the same time

Locking Protocol 2PL

Every transaction begins by obtaining a shared lock on each data object that it needs to read and an exclusive lock on each data object that it needs to modify After completing all actions all the locks are released

e.g. T1 wants to modify X and T2 wants to read X

Incomplete transactions and System crashes

Ensuring Atomicity - DBMS ensures atomicity (all-or-nothing property) even if system crashes in the middle of a Xact. DBMS maintains a log (history) of all actions carried out by the DBMS while executing a set of Xacts: Before a change is made to the database, the corresponding log entry is forced to a safe location WAL write ahead log protocol After a crash, the effects of partially executed transactions are undone using the log.

The Log

The following actions are recorded in the log: Ti writes an object: the old value and the new value. Log record must go to disk before the changed page! Ti commits/aborts: a log record indicating this action. Log records chained together by Xact id, so its easy to undo a specific Xact Log is often duplexed and archived on stable storage. All log related activities (and in fact, all CC related activities such as lock/unlock, dealing with deadlocks etc.) are handled transparently by the DBMS. Time required to recover from crash can be reduced by introducing periodic checkpoints (where information is forced (saved) onto disk)

Databases make these folks happy ...


End users and DBMS implementers (vendors) DB application programmers Database administrator (DBA)

Designs logical /physical schemas Handles security and authorization Data availability, recovery from failures Database tuning as needs evolve

Must thoroughly understand how a DBMS works!

Unsophisticated users (travel agenst, customers)

Sophisticated users, Application Programmers, DBA

Web forms

Application Front ends SQL commands

SQL Interface

Plan Executor
Operator Evaluator

Parser
Optimizer

Query Evaluation Engine

Transaction Manager

Files and Access Methods Buffer Manger Disk Space Manager

A r c h i t e c t u r e o f a D B M S

Lock Manager
Concurrency control

Recovery Manager

database Index files , data files, system catalog

Exercise
Scrooge McNugget wants to store information (names, addresses, descriptions of embarrassing moments, etc.) about the many ducks on his payroll. Not surprisingly, the volume of data compels him to buy a database system. To save money, he wants to buy one with the fewest possible features, and he plans to run it as a stand-alone application on his PC clone. Of course, Scrooge does not plan to share his list with anyone. Indicate which of the following DBMS features Scrooge should pay for; in each case, also indicate why Scrooge should (or should not) pay for that feature in the system he buys. 1. A security facility. 2. Concurrency control. 3. Crash recovery. 4. A view mechanism. 5. A query language.

1. 2. 3. 4.

Which of the following plays an important role in representing information about the real world in a database? Explain briefly. The data definition language. The data manipulation language. The buffer manager. The data model.

Das könnte Ihnen auch gefallen