ch1 intro hh

Upload: mahmoodchatila

Post on 05-Apr-2018

227 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 Ch1 Intro HH

    1/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1

    Database Management Systems

    Chapter 1

    Hazem HajjPresentations based on Course Material

  • 8/2/2019 Ch1 Intro HH

    2/26

  • 8/2/2019 Ch1 Intro HH

    3/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 3

    DBMS A Historical Perspective

    1960s:Data collection, database creation, IDS (early 60s Integrated data store) and network DBMS.ACM Turing Award for Charles Bachman (GE).

    1970s:Relational data model, relational DBMS implementation. ACM Turing Award to EdgardCodd (IBM)

    1980s:RDBMS, advanced data models (extended-relational, OO, deductive, etc.)Application-oriented DBMS (spatial, scientific, engineering, etc.)SQL standard query Language

    1990s:Data mining, data warehousing, multimedia databases, and Web databases

    2000sStream data management and mining Data mining and its applicationsMajor DB Projects: NASAs Earth Observation System and Human Genome Mapping ProjectWeb technology (XML, data integration) and global information systems

  • 8/2/2019 Ch1 Intro HH

    4/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 4

    Why Study Databases??

    Shift from computation to information at the low end : scramble to webspace (a mess!)

    at the high end : scientific applications Datasets increasing in diversity and volume.

    Digital libraries, interactive video, HumanGenome project, EOS project... need for DBMS exploding

    DBMS encompasses most of CSOS, languages, theory, multimedia, logic

    ?

  • 8/2/2019 Ch1 Intro HH

    5/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 5

    Why Study DBMS For data mining

    Data mining Gettingthe golden data nuggetsout of data tombs

    Data Cleaning

    Data Integration

    Databases

    Data Warehouse

    Task-relevant Data

    Selection

    Data Mining

    Pattern Evaluation

  • 8/2/2019 Ch1 Intro HH

    6/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 6

    What Is a DBMS?

    A very large, integrated collection of data.

    Models real-world enterprise (one or morerelated organizations, e.g. university)

    Entities (e.g., students, courses)Relationships (e.g., Obama is taking EECE433)

    A Database Management System (DBMS) is asoftware package designed to store andmanage databases.

  • 8/2/2019 Ch1 Intro HH

    7/26Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 7

    Files vs. DBMS

    Using Files, the programmer would need tohandle:

    Application must stage large datasets betweenmain 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 tomultiple concurrent usersCrash recoverySecurity and access control

  • 8/2/2019 Ch1 Intro HH

    8/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 8

    Why Use a DBMS?A DBMS would address all previous issues. It wouldprovide:

    Data independence (No need to know how the data isstored in a class/data structure)

    Efficient access (e.g. use of indexing and hashing)Reduced application development timeData integrity (e.g. integrity constraints- no grade above 100)and security (need to know access)Uniform data administration (one for all users)Concurrent access (multiple users), recovery from crashes.

    Are there cases where we would not want to use a DBMS?

  • 8/2/2019 Ch1 Intro HH

    9/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 9

    Content

    What is a DBMS? Why use it?Describing and Storing data in a DBMS

    Relational ModelLevels of abstraction

    Queries in DBMS

    Transaction ManagementConcurrent executionIncomplete transaction and system crash

    Structure of a DBMS

  • 8/2/2019 Ch1 Intro HH

    10/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 10

    Describing & Storing Data in aDBMS - Data Models

    The relational model of datais the mostwidely used model today.

    Main concept: relation, basically a table withrows and columns.

    Every relation has a schema, which describes thecolumns, or fields.

    Example: Table with: SID | NAME | LOGIN|AGE

    Semantic data model higher level ofabstraction Use ER model

  • 8/2/2019 Ch1 Intro HH

    11/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 11

    Lec2

  • 8/2/2019 Ch1 Intro HH

    12/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 12

    Describing & Storing Data in aDBMS - Levels of Abstraction

    Three Levels ofAbstractionMany views, single

    conceptual (logical) schemaand physical schema.Views describe how userssee the data.Conceptual schema defines

    logical structurePhysical schema describesthe files and indexes used.

    NOTE Schemas & views are defined using DDL; data is modified/queried using

    DML.

    Physical Schema

    Conceptual Schema

    View 1 View 2 View 3

  • 8/2/2019 Ch1 Intro HH

    13/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 13

    Example: University Database

    Conceptual schema: Students(sid: string, name: string, login: string,

    age: integer, gpa:real)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)

  • 8/2/2019 Ch1 Intro HH

    14/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 14

    Describing & Storing Data in aDBMS - Data Independence *

    Applications insulated from how data isstructured and stored.

    Logical data independence: Protection fromchanges in logical structure of data.Physical data independence: Protection fromchanges in physical structure of data.

    * One of the most important benefits of using a DBMS!

  • 8/2/2019 Ch1 Intro HH

    15/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 15

    Content

    What is a DBMS? Why use it?Describing and Storing data in a DBMS

    Relational ModelLevels of abstraction

    Queries in DBMS

    Transaction ManagementConcurrent executionIncomplete transaction and system crash

    Structure of a DBMS

  • 8/2/2019 Ch1 Intro HH

    16/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 16

    Queries in a DBMS

    What is the name of the student with studentID = 2345?

    How many students are enrolled inEECE433?

    Use SQL

  • 8/2/2019 Ch1 Intro HH

    17/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 17

    Content

    What is a DBMS? Why use it?Describing and Storing data in a DBMS

    Relational ModelLevels of abstraction

    Queries in DBMS

    Transaction ManagementConcurrent executionIncomplete transaction and system crash

    Structure of a DBMS

  • 8/2/2019 Ch1 Intro HH

    18/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 18

    Transaction Management -Concurrency ControlConcurrent execution of user programsis essential for good DBMS performance.

    Because disk accesses are frequent, and relatively

    slow, it is important to keep the cpu humming byworking on several user programs concurrently.

    Interleaving actions of different user programscan lead to inconsistency: e.g., check is clearedwhile account balance is being computed.DBMS ensures such problems dont arise: userscan pretend they are using a single-user system.

  • 8/2/2019 Ch1 Intro HH

    19/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 19

    Transaction Management - Transaction: An Execution of a DB Program

    Key concept is transaction , which is an atomic sequence ofdatabase actions (reads/writes). Atomic => All happensor none.Each transaction, executed completely, must leave the DB

    in a consistent state if DB is consistent when thetransaction 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 semanticsof the data. (e.g., it does not understand how the interest on abank account is computed).Thus, ensuring that a transaction (run alone) preservesconsistency is ultimately the users responsibility!

  • 8/2/2019 Ch1 Intro HH

    20/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 20

    Transaction Management - SchedulingConcurrent Transactions

    DBMS ensures that execution of {T1, ... , Tn} isequivalent 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 thelock. All locks are released at the end of the transaction.(Strict 2PL: Two-Phase locking protocol.)Idea: If an action of Ti (say, writing X) affects Tj (whichperhaps reads X), one of them, say Ti, will obtain thelock 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 alock on Y? (Deadlock!) Ti or Tj is aborted and restarted!

  • 8/2/2019 Ch1 Intro HH

    21/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 21

    Transaction Management - Ensuring Atomicity &Dealing with Incomplete transaction, e.g crash

    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 outby the DBMS while executing a set of Xacts:

    Before a change is made to the database, thecorresponding log entry is forced to a safe location.(WAL: Write Ahead Log protocol; OS support for this isoften inadequate.)After a crash, the effects of partially executedtransactions are undone using the log. (Thanks to WAL, iflog entry wasnt saved before the crash, corresponding

    change was not applied to database!)

  • 8/2/2019 Ch1 Intro HH

    22/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 22

    Transaction Management - 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 toundo 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 relatedactivities such as lock/unlock, dealing with deadlocksetc.) are handled transparently by the DBMS.

  • 8/2/2019 Ch1 Intro HH

    23/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 23

    Content

    What is a DBMS? Why use it?Describing and Storing data in a DBMS

    Relational ModelLevels of abstraction

    Queries in DBMS

    Transaction ManagementConcurrent executionIncomplete transaction and system crash

    Structure of a DBMS

  • 8/2/2019 Ch1 Intro HH

    24/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 24

    Structure of a DBMS

    A typical DBMS has alayered architecture.

    This is one of severalpossible architectures;each system has its ownvariations.

    Query Optimizationand Execution

    Relational OperatorsFiles and Access Methods

    Buffer Management

    Disk Space Management

    DB

    concurrencycontrolandrecovery

    SQL Commands

  • 8/2/2019 Ch1 Intro HH

    25/26

    Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 25

    Databases make these folks happy ...

    End users and DBMS vendorsDB application programmers

    E.g. smart webmastersDatabase administrator (DBA)

    Designs logical /physical schemasHandles security and authorizationData availability, crash recoveryDatabase tuning as needs evolve

    Must understand how a DBMS works!

  • 8/2/2019 Ch1 Intro HH

    26/26

    Database Management Systems 3ed R Ramakrishnan and J Gehrke 26

    SummaryDBMS 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 jobsand are well-paid !DBMS R&D is one of the broadest,most exciting areas in CS.