CENG%20352%20Database%20Management%20Systems - PowerPoint PPT Presentation

About This Presentation
Title:

CENG%20352%20Database%20Management%20Systems

Description:

... editing the same UNIX file last to write 'wins' with the ... UPDATE relation name SET attribute = new-value WHERE condition SPRING 2004 S ... – PowerPoint PPT presentation

Number of Views:66
Avg rating:3.0/5.0
Slides: 30
Provided by: nihankes
Category:

less

Transcript and Presenter's Notes

Title: CENG%20352%20Database%20Management%20Systems


1
CENG 352 Database Management Systems
  • Instructor Nihan Kesim Çiçekli
  • email nihan_at_ceng.metu.edu.tr
  • URL http//www.ceng.metu.edu.tr/nihan

2
CENG 352
  • Instructor Nihan Kesim Çiçekli
  • Office A308
  • Email nihan_at_ceng.metu.edu.tr
  • Lecture Hours Mon. 1440,1540 (BMB4) Thu.
    1340 (BMB2)
  • Office Hours Fri. 1040-1130
  • Course Web page http//www.ceng.metu.edu.tr/semr
    a/nli/ceng352
  • Teaching Assistant Semra Dogandag
    (semra_at_ceng.metu.edu.tr)

3
Text Books and References
  1. Raghu Ramakrishnan, Database Management Systems,
    McGraw Hill, 3rd edition, 2003 (text book).
  2. R. Elmasri, S.B. Navathe, Fundamentals of
    Database Systems, 4th edition, Addison-Wesley,
    2004.
  3. A. Silberschatz, H.F. Korth, S. Sudarshan,
    Database System Concepts, McGraw Hill, 4th
    edition, 2002.
  4. H. Garcia-Molina, J. D. Ullman, J. Widom,
    Database Systems The Complete Book, Prentice
    Hall, 2002.

4
Grading
  • Written assignments 15
  • Project 20
  • Midterm Exam 30
  • Final 35
  • Exam Date
  • Midterm Exam 2nd week of April.

5
Grading Policies
  • Policy on missed midterm
  • no make-up exam
  • Lateness policy
  • Late assignments are penalized up to 10 per day.
  • All assignments are to be your own work. Projects
    in groups of two.

6
Course Outline
  • The Relational Data Model, Relational Algebra and
    Calculus, SQL
  • Query Evaluation and Optimization
  • Relational Database Design and Tuning
  • Transaction Management, Concurrency Control and
    Crash Recovery
  • Database Security and Authorization
  • Parallel and Distributed Databases
  • Object-Database Systems
  • Information Retrieval and XML Data

7
What is a Database Management System?
  • A Database Management System (DBMS) is a software
    package designed to store and manage databases
  • Manages very large amounts of data.
  • 2. Supports efficient access to very large
    amounts of data.
  • 3. Supports concurrent access to very large
    amounts of data.
  • Example bank and its ATM machines.
  • 4. Supports secure, atomic access to very large
    amounts of data.
  • Contrast two people editing the same UNIX file
    last to write wins with the problem if two
    people deduct money from the same account via ATM
    machines at the same time new balance is wrong
    whichever writes last.

8
Example Online Bookseller
  • Data information on books (including
    categories, bestsellers, etc.), customers,
    pending orders, order histories, trends and
    preferences, etc.
  • Massive many gigabytes at a minimum for
    medium-size bookseller, more if keep all order
    histories over all time, even more if keep images
    of book covers and sample pages
  • gt Far too big for memory
  • Persistent data outlives programs that operate
    on it
  • Multi-user many people/programs accessing same
    database, or even same data, simultaneously
  • gt Need careful controls

9
Files vs. DBMS
  • Application must stage large datasets between
    main memory and secondary storage (e.g.,
    buffering, page-oriented access, 32-bit
    addressing, etc.)
  • Special code for different queries
  • Must protect data from inconsistency due to
    multiple concurrent users
  • Crash recovery
  • Security and access control

10
What is a Relational Database?
  • Based on the relational model (tables)
  • acct name balance
  • 12345 Sally 1000.21
  • 34567 Sue 285.48
  • Today used in most DBMS's.

11
The DBMS Marketplace
  • Relational DBMS companies Oracle, Sybase are
    among the largest software companies in the
    world.
  • IBM offers its relational DB2 system. With IMS,
    a nonrelational system, IBM is by some accounts
    the largest DBMS vendor in the world.
  • Microsoft offers SQL-Server, plus Microsoft
    Access for the cheap DBMS on the desktop,
    answered by lite systems from other
    competitors.
  • Relational companies also challenged by
    object-oriented DB companies.
  • But countered with object-relational systems,
    which retain the relational core while allowing
    type extension as in OO systems.

12
Three Aspects to Studying DBMS's
  • 1. Modeling and design of databases.
  • Allows exploration of issues before committing to
    an implementation.
  • 2. Programming queries and DB operations like
    update.
  • SQL intergalactic dataspeak.
  • 3. DBMS implementation.

13
Query Languages
Employee
Department
Name
Dept
Dept
Manager
SQL
  • SELECT ManagerFROM Employee, DepartmentWHERE
    Employee.name "Clark Kent AND Employee.Dept
    Department.Dept
  • Query Language Data definition language (DDL)
    like type defs in C or Pascal
  • Data Manipulation Language (DML) Query
    (SELECT) UPDATE lt relation name gt SET
    ltattributegt lt new-valuegt WHERE ltconditiongt

14
Host Languages
C, C, Java, Lisp, COBOL
Application prog.
DBMS
Calls to DB
Local Vars
(Memory)
(Storage)
  • Host language is completely general (Turing
    complete)
  • Query languageless general "non procedural" and
    optimizable

15
Relational Model
  • Relational model is good for
  • Large amounts of data gt simple operations
  • Navigate among small number of relations
  • Difficult Applications for relational model
  • VLSI Design (CAD in general)
  • CASE
  • Graphical Data

16
Other Models
  • Where number of "relations" is large,
    relationships are complex
  • Object Data Model
  • Logic Data Model
  • OBJECT DATA MODEL
  • 1. Complex Objects Nested Structure (pointers
    or references)
  • 2. Encapsulation, set of Methods/Access functions
  • 3. Object Identity
  • 4. Inheritance Defining new classes like old
    classes
  • Object model usually find objects via explicit
    navigation
  • Also query language in some systems

17
Other Models
  • LOGIC (Horn Clause) DATA MODEL
  • Prolog, Datalog
  • if A1 and A2 then B
  • B- A1 and A2
  • Functions s(5) 6 (successor)
  • Predicates with Arguments sum(X,Y,Z) ? X Y
    Z
  • sum(X,0,X) means X 0 X (always true for all
    X)
  • sum(X,s(Y),s(Z))-sum(X,Y,Z) means X(Y1)
    (Z1) if X Y Z
  • More powerful than relational
  • Can Compute Transitive Closure
  • edge(X,Y).
  • path(X,Y) - edge(X,Y).
  • path(X,Z) - path(X,Y) edge(Y,Z).

18
Data Models
60s 70's 80's 90s now
Hierarchical
Network
Relational
Choice for most new applications
Object Bases
Knowledge Bases
19
Why Use a DBMS?
  • Data independence and efficient access.
  • Reduced application development time.
  • Data integrity and security.
  • Uniform data administration.
  • Concurrent access, recovery from crashes.

20
Data Independence
  • Applications insulated from how data is
    structured and stored.
  • Logical data independence Protection from
    changes in logical structure of data.
  • Physical data independence Protection from
    changes in physical structure of data.
  • One of the most important benefits of using a
    DBMS!

21
Levels of Abstraction
  • Many views, single conceptual (logical) schema
    and physical schema.
  • Views describe how users see the data.
  • Conceptual schema defines logical structure
  • Physical schema describes the files and indexes
    used.

View 1
View 2
View 3
Conceptual Schema
Physical Schema
  • Schemas are defined using DDL data is
    modified/queried using DML.

22
Concurrency Control
  • Concurrent execution of user programs is
    essential for good DBMS performance.
  • Because disk accesses are frequent, and
    relatively slow, it is important to keep the cpu
    humming by working on several user programs
    concurrently.
  • Interleaving actions of different user programs
    can lead to inconsistency e.g., check is cleared
    while account balance is being computed.
  • DBMS ensures such problems dont arise users
    can pretend they are using a single-user system.

23
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.
  • Users can specify some simple integrity
    constraints on the data, and the DBMS will
    enforce these constraints.
  • Beyond this, the DBMS does not really understand
    the semantics of the data. (e.g., it does not
    understand how the interest on a bank account is
    computed).
  • Thus, ensuring that a transaction (run alone)
    preserves consistency is ultimately the users
    responsibility!

24
Scheduling Concurrent Transactions
  • DBMS ensures that execution of T1, ... , Tn is
    equivalent to some serial execution T1 ... Tn.
  • Before reading/writing an object, a transaction
    requests a lock on the object, and waits till the
    DBMS gives it the lock. All locks are released
    at the end of the transaction. (Strict 2PL
    locking protocol.)
  • Idea If an action of Ti (say, writing X) affects
    Tj (which perhaps reads X), one of them, say Ti,
    will obtain the lock on X first and Tj is forced
    to wait until Ti completes this effectively
    orders the transactions.
  • What if Tj already has a lock on Y and Ti later
    requests a lock on Y? (Deadlock!) Ti or Tj is
    aborted and restarted!

25
Ensuring Atomicity
  • DBMS ensures atomicity (all-or-nothing property)
    even if system crashes in the middle of a Xact.
  • Idea Keep 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 protocol OS support for this is
    often inadequate.)
  • After a crash, the effects of partially executed
    transactions are undone using the log. (Thanks to
    WAL, if log entry wasnt saved before the crash,
    corresponding change was not applied to database!)

26
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 (e.g., to resolve a
    deadlock).
  • 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.

27
Databases make these folks happy
  • End users and DBMS vendors
  • DB application programmers
  • e.g., smart webmasters
  • Database administrator (DBA)
  • Designs logical /physical schemas
  • Handles security and authorization
  • Data availability, crash recovery
  • Database tuning as needs evolve

Must understand how a DBMS works!
28
Structure of a DBMS
These layers must consider concurrency control
and recovery
  • A typical DBMS has a layered architecture.
  • The figure does not show the concurrency control
    and recovery components.
  • This is one of several possible architectures
    each system has its own variations.

29
Summary
  • DBMS used to maintain, query large datasets.
  • Benefits include recovery from system crashes,
    concurrent access, quick application development,
    data integrity and security.
  • Levels of abstraction give data independence.
  • A DBMS typically has a layered architecture.
  • DBAs hold responsible jobs
    and are well-paid! ?
  • DBMS RD is one of the broadest,
    most exciting areas
    in CS.
Write a Comment
User Comments (0)
About PowerShow.com