Presentation is loading. Please wait.

Presentation is loading. Please wait.

Overview of Database Systems Yanlei Diao University of Massachusetts Amherst.

Similar presentations


Presentation on theme: "Overview of Database Systems Yanlei Diao University of Massachusetts Amherst."— Presentation transcript:

1 Overview of Database Systems Yanlei Diao University of Massachusetts Amherst

2 6/20/2015 Yanlei Diao, University of Massachusetts Amherst Outline An outside look: DB Application An inside look: Anatomy of DBMS

3 6/20/2015 Yanlei Diao, University of Massachusetts Amherst Database Management System (DBMS): a software package designed to store and manage a large amount of data An Outside Look: DB Application DBMS Persistent storage Performance Concurrency Automatic recovery Security… High-level, declarative interface

4 6/20/2015 Yanlei Diao, University of Massachusetts Amherst Case Study: The Internet Shop* DBDudes Inc.: a well-known database consulting firm Barns and Nobble (B&N): a large bookstore specializing in books on horse racing B&N decides to go online, asks DBDudes to help with the database design and implementation Step 0: DBDudes makes B&N agree to –pay steep fees and –schedule a lunch meeting for requirements analysis * The example and all related material was taken from “Database Management Systems” Edition 3.

5 6/20/2015 Yanlei Diao, University of Massachusetts Amherst Step 1: Requirements Analysis “I’d like my customers to be able to browse my catalog of books and place orders online.” –Books: For each book, B&N’s catalog contains its ISBN number, title, author, price, year of publication, … –Customers: Most customers are regulars with names and addresses registered with B&N. New customers must first call and establish an account. –On the new website: Customers identify themselves before browsing and ordering. Each order contains the ISBN of a book and a quantity. –Shipping: For each order, B&N ships all copies of a book together once they become available.

6 6/20/2015 Yanlei Diao, University of Massachusetts Amherst A high level description of the data in terms of the Entity- Relationship (ER) model. Design review: –What if a customer places two orders of the same book in one day? –Modification: add “ordernum” to Orders. Step 2: Conceptual Design cardnum ship_date BooksCustomers Orders isbn title author qty_in_stock price Year cidaddress cname order_date qty ordernum

7 6/20/2015 Yanlei Diao, University of Massachusetts Amherst Step 3: Logical Design Mapping the ER diagram to the relational model Access control: use views to restrict the access of certain employees to customer sensitive information CREATE TABLE Books (isbnCHAR(10), titleCHAR(80), authorCHAR(80), qty_in_stock INTEGER, priceREAL, yearINTEGER, PRIMARY KEY(isbn)) CREATE TABLE Customers (cidINTEGER, cnameCHAR(80), addressCHAR(200), PRIMARY KEY(cid)) CREATE TABLE Orders (ordernum INTEGER, isbnCHAR(10), cidINTEGER, cardnumCHAR(16), qty INTEGER, order_date DATE, ship_date DATE, PRIMARY KEY(ordernum, isbn), FOREIGN KEY (isbn) REFERENCES Books, FOREIGN KEY (cid) REFERENCES Customers) CREATE VIEW OrderInfo (isbn, cid, qty, order_date, ship_date) AS SELECT O.isbn, O.cid, O.qty, O.order_date, O.ship_date FROM Orders O CREATE VIEW OrderInfo (isbn, cid, qty, order_date, ship_date) AS SELECT O.isbn, O.cid, O.qty, O.order_date, O.ship_date FROM Orders O

8 6/20/2015 Yanlei Diao, University of Massachusetts Amherst Step 4: Schema Refinement ordernumisbncidcardnumqtyorder_dateship_date 1200-07-11123402411602Jan 3, 2006Jan 6, 2006 1201-12-23123402411601Jan 3, 2006Jan 11, 2006 1200-07-24123402411603Jan 3, 2006Jan 26, 2006 120 ordernum 120 isbn 0-07-11 1-12-23 0-07-24 qty 2 1 3Jan 26, 2006 ship_date Jan 6, 2006 Jan 11, 2006 ordernum 120 cid 123 cardnum 40241160 order_date Jan 3, 2006 Orders Orderlists Redundant Storage!

9 6/20/2015 Yanlei Diao, University of Massachusetts Amherst Step 5: Internet Application Development Database System (DB2, MySQL…) Application Server (Apache Tomcat…) Client Program (Web Browser) Presentation tier Application logic tier Data management tier Interface to the user Adapt to display devices Business logic (actions, state between steps) Access multiple sources One/multiple DBMS(s) B&N Data: Books Customers (User login) Orders Orderlists B&N Business logic: Home page Login page Search page Cart page Confirm page HTML, Javascript, Cookies JSP, Servlets, XSLT XML, stored procedures HTTP JDBC B&N Client: User input Session state

10 6/20/2015 Yanlei Diao, University of Massachusetts Amherst An Example Internet Store

11 6/20/2015 Yanlei Diao, University of Massachusetts Amherst Example SQL Queries SELECTisbn, title, author, price FROM Books WHERE isbn = '% %' ORDER BY title Search Page SELECTcid, username, password FROM Customers WHERE username = ' ' Login Page INSERT INTO Orders (cid, cardnum, order_date) VALUES (,, ) SELECT ordernum FROM Orders WHERE CID = ORDER BY ordernum DESC INSERT INTO Orderlists (ordernum, isbn, qty) VALUES (,, ) Confirm Page

12 6/20/2015 Yanlei Diao, University of Massachusetts Amherst Step 6: Physical Design Good performance for typical workloads Auxiliary data structures (indices) to speed up searches Books Hash Index on Books.isbn Spectacular Bid title Legacies of the Turf Seattle Slew isbn 0-07-11 1-12-23 0-07-24 qty 10 0 3 Timothy Capps author Edward L. Bowen Dan Mearns price 29.95 24.95 16.95 year 2003 2000 2001 … …… … …… … …… … …… … …… … …… … …… … …… … …… … …… H1 1 2 3 … … … … … … N-1 isbn number

13 6/20/2015 Yanlei Diao, University of Massachusetts Amherst Outline An outside look: DB Application An inside look: Anatomy of DBMS

14 6/20/2015 Yanlei Diao, University of Massachusetts Amherst DBMS An Inside Look: Anatomy of DBMS Query Parser Query Rewriter Query Optimizer Query Executor Query Processor Transactional Storage Manager Disk Space Manager DB Access Methods Buffer Manager Lock Manager Log Manager Disk Manager

15 6/20/2015 Yanlei Diao, University of Massachusetts Amherst Query Processor Query Parser Query Rewriter Query Optimizer Query Executor SELECTC.cname, F.ordernum, F.order_date FROMCustomers C, OrderInfo F WHEREC.cname = “John” C.cid = F.cid Syntax checking Internal representation Handling views Logical/semantic rewriting Flattening subqueries Building a query execution plan Efficient, if not optimal − Define plan space − Cost estimation for each − Search algorithm Pull-based execution of a plan Each operator is an Iterator: init(), next()*, close() SELECTC.cname, O.ordernum, O.order_date FROMCustomers C, Orders O WHEREC.cname = “John” C.cid = O.cid IndexScan Customers cname=“John” IndexScan Orders cid=cid C.cname, O.ordernum, O.order_date (Indexed Join) (On-the-fly)

16 6/20/2015 Yanlei Diao, University of Massachusetts Amherst Transactional Storage Manager Access Methods Buffer Manager Lock ManagerLog Manager IndexScan Customers cname=“John” IndexScan Orders cid=cid C.cname, O.ordernum, O.order_date (Indexed Join) (On-the-fly) Replacement policy, Support for Concurrency & Recovery Concurrency: 2PL Recovery: WAL Heap file, B+tree, Hash

17 6/20/2015 Yanlei Diao, University of Massachusetts Amherst Disk Manager Disk Space Manager Buffer Manager Allocate/Deallocate a page Read/Write a page Contiguous seq. of pages Data IndicesCatalog Log Database Heap file Page format Record format

18 6/20/2015 Yanlei Diao, University of Massachusetts Amherst DBMS: Theory + Systems Theory! Query Parser Query Rewriter Query Optimizer Query Executor Disk Space Manager DB Access Methods Buffer Manager Lock Manager Log Manager Systems!

19 6/20/2015 Yanlei Diao, University of Massachusetts Amherst Questions


Download ppt "Overview of Database Systems Yanlei Diao University of Massachusetts Amherst."

Similar presentations


Ads by Google