Database Application Design
description
Transcript of Database Application Design
![Page 1: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/1.jpg)
(C) 2000, The University of Michigan
1
Database Application Design
Handout #8
February 25, 2000
![Page 2: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/2.jpg)
(C) 2000, The University of Michigan
2
Course information
• Instructor: Dragomir R. Radev ([email protected])
• Office: 305A, West Hall
• Phone: (734) 615-5225
• Office hours: Thursdays 3-4 and Fridays 1-2
• Course page: http://www.si.umich.edu/~radev/654w00
• Class meets on Fridays, 2:30 - 5:30 PM, 311 WH
![Page 3: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/3.jpg)
(C) 2000, The University of Michigan
3
Managing multi-user databases(cont’d)
![Page 4: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/4.jpg)
(C) 2000, The University of Michigan
4
Concurrency control
• Lax and strict policies
• Atomic transactions (LUWs = logical units of work)– Example: customer+salesperson
• Concurrent transaction processing: interlocking
• Lost update problem
![Page 5: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/5.jpg)
(C) 2000, The University of Michigan
5
Example
• User A:– Read item 100– Reduce by 5– Write item 100
• User B:– Read item 200– Reduce by 3– Write item 200
![Page 6: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/6.jpg)
(C) 2000, The University of Michigan
6
Resource locking
• Locks: implicit, explicit
• Example: two users
![Page 7: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/7.jpg)
(C) 2000, The University of Michigan
7
Example
• User A:– Lock item 100– Read item 100– Reduce by 5– Write item 100
• User B:– Lock item 100– Read item 100– Reduce by 3– Write item 100
![Page 8: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/8.jpg)
(C) 2000, The University of Michigan
8
Example (cont’d)1. Lock item 100 for A
2. Read item 100 for A
3. Lock item 100 for B; cannot
4. Decrease 100 by 5
5. Write item 100 for A
6. Release A’s lock on 100
7. Lock item 100 for B
8. Read item 100 for B
9. Decrease item 100 by 3
10. Write 100 for B
11. Release B’s lock on 100
![Page 9: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/9.jpg)
(C) 2000, The University of Michigan
9
Resource locking
• Serizalizable transaction– 2PL: growing phase, followed by a shrinking
phase
• COMMIT and ROLLBACK
• DEADLOCKS
![Page 10: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/10.jpg)
(C) 2000, The University of Michigan
10
Transaction isolation levels
• Exclusive use
• Repeatable read: mix of shared and exclusive locks
• Dirty read: for reports which don’t necessarily need to contain the latest data
![Page 11: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/11.jpg)
(C) 2000, The University of Michigan
11
Cursor types
• Forward only: changes made to earlier records are hidden
• Static: any changes are hidden
• Dynamic: all changes are visible
![Page 12: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/12.jpg)
(C) 2000, The University of Michigan
12
Database recovery
• Reprocessing: uses database saves
• Rollback/Rollforward : uses transaction logs, before-images, and after-images
![Page 13: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/13.jpg)
(C) 2000, The University of Michigan
13
Database security
• Users, groups, permissions, objects
• Permissions:– CONNECT: ALTER SESSION, CREATE
TABLE, CREATE VIEW
![Page 14: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/14.jpg)
(C) 2000, The University of Michigan
14
Application security
• Usually done on the Web server
• ASP script modifies SQL statement:
SELECT *FROM EMPLOYEE<% WHERE EMPLOYEE.Name “=SESSION(“EmployeeName”)”%>
![Page 15: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/15.jpg)
(C) 2000, The University of Michigan
15
Sharing enterprise data
![Page 16: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/16.jpg)
(C) 2000, The University of Michigan
16
Enterprise DB architectures
• Teleprocessing systems
• Client-server systems
• File-sharing systems
• Distributed database systems: vertical and horizontal fragmentation
![Page 17: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/17.jpg)
(C) 2000, The University of Michigan
17
Comparing distributed DB architectures
Unified database
Distributed databases
Single Nonpartitioned Nonreplicated
Partitioned Nonreplicated
Nonpartitioned Replicated
Partitioned Replicated
Increased security risk
Increased difficulty of control
Increased cost/complexity
Increased availability
Increased flexibility
Increased independence
Increased parallelism+
+
+
+
+
+
+
-
-
-
-
+
+
+
![Page 18: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/18.jpg)
(C) 2000, The University of Michigan
18
Problems in downloaded databases
• Coordination
• Consistency
• Access control
• Computer crime
![Page 19: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/19.jpg)
(C) 2000, The University of Michigan
19
On Line Analytic Processing (OLAP)
• Hypercubes, axes, dimensions, slices
• Values of a dimension are called members
• Levels: hierarchical organization: e.g., date, month, year
• CROSSJOIN ({Existing Structure, New Construction}, {California.Children, Nevada})
![Page 20: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/20.jpg)
20
OLAP SQLCREATE CUBE HousingSalesCube ( DIMENSION Time TYPE TIME, LEVEL Year TYPE YEAR, LEVEL Quarter TYPE QUARTER, LEVEL Month TYPE MONTH, DIMENSION Location, LEVEL USA TYPE ALL, LEVEL State, LEVEL City, DIMENSION HousingCategory, DIMENSION HousingType, MEASURE SalesPrice, FUNCTION AVG, MEASURE AskingPrice, FUNCTION AVG)
![Page 21: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/21.jpg)
(C) 2000, The University of Michigan
21
KDD: Data Mining
![Page 22: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/22.jpg)
(C) 2000, The University of Michigan
22
Association rules
• X Y
• 65% of all customers who buy beer and tomato sauce also buy pasta and chicken wings
• Support (X)
• Confidence (X Y) = Support(X+Y) / Support (X)
![Page 23: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/23.jpg)
(C) 2000, The University of Michigan
23
Object-oriented data processing
![Page 24: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/24.jpg)
(C) 2000, The University of Michigan
24
Introduction
• OOP objects: encapsulated structures with attributes and methods
• Interface + implementation
• Inheritance
• Polymorphism
• Transient and persistent objects
![Page 25: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/25.jpg)
(C) 2000, The University of Michigan
25
Final project guidelines
![Page 26: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/26.jpg)
26
ChecklistIntroductionUser interviews/needs: table, reports, queries, formsInitial data modelER modelDecompositionSQL codeDocumentationEvaluation, Future workScheduleSustainabilitySnapshotsPresentationDemo
![Page 27: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/27.jpg)
(C) 2000, The University of Michigan
27
Grading
• Project: 40%- design 10%- implementation 10%- documentation 10%- presentation+demo 10%
![Page 28: Database Application Design](https://reader035.fdocuments.net/reader035/viewer/2022081519/568145ec550346895db2eeda/html5/thumbnails/28.jpg)
(C) 2000, The University of Michigan
28
Readings for next time
• Kroenke– Chapter 14: Sharing Enterprise Data
– Chapter 17: Object-Oriented Database Processing
• YRK (optional)– Chapter 14: Java and JDBC