1 / 29

CENG 352 Database Management Systems

CENG 352 Database Management Systems. Instructor: Nihan Kesim Çiçekli email: nihan@ceng.metu.edu.tr URL: http://www.ceng.metu.edu.tr/~nihan. CENG 352. Instructor: Nihan Kesim Çiçekli Office: A308 Email : nihan@ceng.metu.edu.tr

gerardoe
Télécharger la présentation

CENG 352 Database Management Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. CENG 352 • Instructor: Nihan Kesim Çiçekli • Office: A308 • Email: nihan@ceng.metu.edu.tr • Lecture Hours: Mon. 14:40,15:40 (BMB4); Thu. 13:40 (BMB2) • Office Hours: Fri. 10:40-11:30 • Course Web page:http://www.ceng.metu.edu.tr/~semra/nli/ceng352 • Teaching Assistant: Semra Doğandağ (semra@ceng.metu.edu.tr) CENG 352

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

  4. Grading Written assignments 15% Project 20% Midterm Exam 30% Final 35% Exam Date: Midterm Exam: 2nd week of April. CENG 352

  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. CENG 352

  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 CENG 352

  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. CENG 352

  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 => 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 => Need careful controls CENG 352

  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 CENG 352

  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. CENG 352

  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. CENG 352

  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. CENG 352

  13. Query Languages Employee Department 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 < relation name > SET <attribute> = < new-value> WHERE <condition> Name Dept Dept Manager SQL CENG 352

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

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

  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 CENG 352

  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+(Y+1) = (Z+1) 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). CENG 352

  18. Data Models 60’s 70's 80's 90’s now Hierarchical Network Relational Choice for most new applications Object Bases Knowledge Bases CENG 352

  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. CENG 352

  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! CENG 352

  21. Levels of Abstraction • Many views, single conceptual (logical) schemaand 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. CENG 352

  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 don’t arise: users can pretend they are using a single-user system. CENG 352

  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 stateif DB is consistent when the transaction begins. • Users can specify some simple integrity constraintson 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 user’s responsibility! CENG 352

  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 abortedand restarted! CENG 352

  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 wasn’t saved before the crash, corresponding change was not applied to database!) CENG 352

  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 it’s 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. CENG 352

  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! CENG 352

  28. Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management DB 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. CENG 352

  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 R&D is one of the broadest, most exciting areas in CS. CENG 352

More Related