LeongHW, SOC, NUS (UIT2201:3 Database) Page 1 Copyright © 2007-9 by Leong Hon Wai Database – Info Storage and Retrieval  Aim: Understand basics of  Info.

Slides:



Advertisements
Similar presentations
GCSE ICT By the end of this session, you will be able to: Explain main features of ATM machines Identify features of credit cards, debit cards, smart cards.
Advertisements

Chapter 4: Requirements Engineering
Reconcile a Bank Statement
LeongHW, SoC, NUS (UIT2201: Algorithms) Page 1 © Leong Hon Wai, Animation of Algorithm Goal: To understand an algorithm by animating its execution,
Using the School Report Card Online Application
Concurrency Control WXES 2103 Database. Content Concurrency Problems Concurrency Control Concurrency Control Approaches.
Accessing data Transactions. Agenda Questions from last class? Transactions concurrency Locking rollback.
1COM6030 Systems Analysis and Design © University of Sheffield 2005 COM 6030 Software Analysis and Design Lecture 7 – More on use cases and activity diagrams.
Introduction to Software Testing Chapter 2.6 Graph Coverage for Use Cases Paul Ammann & Jeff Offutt
USE CASE – ATM EXAMPLE Actors: ATM Customer ATM Operator Use Cases: The customer can withdraw funds from a checking or savings account query the balance.
SWE 214 (071) Use Case Diagrams Slide 1 Use Case Diagrams Examples.
Employee Online Tutorial. Employee ID Employee Id is the 3 or 4 digit # Assigned by Payroll, Employee Id must be preceded by 5 or 4 Zeros to be a total.
CPSC 333: Foundations of Software EngineeringJ. Denzinger Small Test: Bank account manager System has to run on an automated teller machine. User must.
LeongHW, SOC, NUS (UIT2201:3 Database) Page 1 Copyright © by Leong Hon Wai Database – Info Storage and Retrieval  Aim: Understand basics of  Info.
Introduction to Software Testing Chapter 2.6 Graph Coverage for Use Cases Paul Ammann & Jeff Offutt
Data and Database Administration Chapter 12. Outline What is Concurrency Control? Background Serializability  Locking mechanisms.
Sequence Diagrams. Introduction A Sequence diagram depicts the sequence of actions that occur in a system. The invocation of methods in each object, and.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 16 – Intro. to Transactions.
Tutorial 2. What is a UML Use Case Diagram? Use case diagrams model the functionality of a system using actors and use cases. Use cases are services or.
CS444/CS544 Operating Systems Synchronization 2/16/2006 Prof. Searleman
Data Flow Diagram Notations
{ How to Use An ATM A simple tutorial to teach how to use ATM Machines.
INTERACTION DIAGRAMS Example Kingdom of Saudi Arabia Ministry of Higher Education Princess Noura bint Abdulrahman University College of Computer & Information.
2.3 Examples: Ski resort information system
Use Cases 2 ENGR ♯10 Peter Andreae
Merijn Benjamin Christina
LeongHW, SoC-USP, NUS (UTT2201: Introduction) Page 1 © Leong Hon Wai, UIT2201: Lecture 1  Lecture Outline: 1.The Pervasive Computer 2.Examples.
LeongHW, SOC, NUS (UIT2201:3 Database) Page 1 Copyright © by Leong Hon Wai Database – Info Storage and Retrieval  Aim: Understand basics of  Info.
QuickBooks Overview Home Bank Account / Register Transactions Deposits Withdrawals / Checks Reconciliations Reports Live Tutorial of QuickBooks Jason Foster.
Glenn David Blank Computer Science & Engineering Department Lehigh University, Bethlehem, PA, USA With support from the National Science Foundation (Grants.
LeongHW, SoC, NUS (UIT2201: Database) Page 1 © Leong Hon Wai, Animation of SQL Queries To illustrate three SQL queries: –Q1: simple select (one.
LeongHW, SOC, NUS (UIT2201:3 Database) Page 1 Copyright © by Leong Hon Wai Database – Info Storage and Retrieval  Aim: Understand basics of  Info.
LeongHW, SoC, NUS (UIT2201: AI) Page 1 © Leong Hon Wai, Integrating Different Ideas Together  Reading Materials:  Ch 3.6 of [SG]  Contents:
Faculty of Computer & Information Software Engineering Third year
Chapter 3, Section 3 ELECTRONIC BANKING.
ICT and Banks Banks use mainframe computers to maintain customer accounts. They store a record of each customer’s withdrawals and deposits. Each bank mainframe.
Transaction processing Book, chapter 6.6. Problem: With a single user…. you run a query, you get the results, you run the next, etc. But database life.
Recall The Team Skills 1. Analyzing the Problem (with 5 steps) 2. Understanding User and Stakeholder Needs 3. Defining the System 4. Managing Scope 5.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 25.1 Test-Driving the ATM Application 25.2.
1 Graph Coverage (6). Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Section
LeongHW, SoC, NUS (UIT2201: Networks) Page 1© Leong Hon Wai, (MACP) Medium Access Control Protocol.
© Leong Hon Wai, LeongHW, SoC, NUS (UIT2201: Algorithms) Page 1 Animation of Algorithm Goal: To understand an algorithm by animating its execution,
Events & Messages Merijn Paul Tom. Generic Exceptions  HardwareFail – the device does not respond  HardwareMalfunction – some part of the device is.
User Manual For ATM Cash Withdrawal. ATM Cash withdrawal-Manual Pikachu will guide you throughout the ATM cash withdrawal process.
Instructor: Craig Duckett Lecture 07: Tuesday, October 20 th, 2015 Conflicts and Isolation, MySQL Workbench 1 BIT275: Database Design (Fall 2015)
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 16 – Intro. to Transactions.
Lecture Outline Monday 23 rd February (Week 4) 3 – 3:10pm Review of Requirements Eng. and use cases 3:10 – 3:40pm Exercise on Use Case 3:40-4:40 Class.
Requirements Document for the Banking System
Introduction to Database Systems 1. Pop Quiz Question 1: How often do you use a database system or database system application? a)At least once a day.
LeongHW, SoC&USP, NUS (UTT2201: Introduction) Page 1 © Leong Hon Wai, UIT2201: CS & IT Revolution  Assessment:  Participation: 05 %  Tutorials:20.
1 Case Study and Use Cases for Case Study Lecture # 28.
Employee / Employer Self Service  An Introduction to Premier ESS.
CMPE 280 Web UI Design and Development August 29 Class Meeting
Structured Analysis and Design Technique
How does it work? What is it made of? What is it made of?
Recall The Team Skills Refining the Use cases
Dynamic Modeling of Banking System Case Study - I
Object-Oriented Static Modeling of the Banking System - I
Ch 21: Transaction Processing
Employee Self Service An Introduction to Premier ESS.
Paul Ammann & Jeff Offutt
CSE 486/586 Distributed Systems Concurrency Control --- 1
Concurrency Control WXES 2103 Database.
Accessing Your MySQL Database from the Web with PHP (Ch 11)
SECTION 4-4 Bank Statements pp
Smart Business for eGeneration Companies
Level 1 Module 2 Lesson 5 AXS Machines.
Real-Time Structured Analysis and Design Technique (RSTAD)
CSE 486/586 Distributed Systems Concurrency Control --- 1
Smart Business for eGeneration Companies
Presentation transcript:

LeongHW, SOC, NUS (UIT2201:3 Database) Page 1 Copyright © by Leong Hon Wai Database – Info Storage and Retrieval  Aim: Understand basics of  Info storage and Retrieval;  Database Organization;  DBMS, Query and Query Processing;  Work some simple exercises;  Concurrency Issues (in Database)  Readings:  [SG] --- Ch 13.3  Optional:  Some experiences with MySQL, Access

LeongHW, SOC, NUS (UIT2201:3 Database) Page 2 Copyright © by Leong Hon Wai Coffee Awards in UIT2201 Coffee awards goes to  interesting, creative things done in tutorials,  good attempt on A-problems,  interesting suggestions or comments in class  Claim them anytime  Just me  To get a coffee and chat

LeongHW, SOC, NUS (UIT2201:3 Database) Page 3 Copyright © by Leong Hon Wai Concurrency Issues  Concurrency  When 2 processes access S at the same time!  Can cause all kinds of problems  Important issue in all areas  Illustrate with concurrency issue in database  Readings for Concurrency Issues  Record Locking – Wikipedia u  Read [SG3] Section (pp ) u Efficient Allocation and Safe Use of Resources

LeongHW, SOC, NUS (UIT2201:3 Database) Page 4 Copyright © by Leong Hon Wai Concurrency Issue: Example  Bank account info: Withdraw-P (amt); begin check balance; bal  bal - amt; end; Deposit-P (amt); begin check balance; bal  bal + amt; end;  Deposit and Withdrawal Processes B ANK -A CCOUNT-DB Account #NameBalanceOther Info… Albert Bank5000…

LeongHW, SOC, NUS (UIT2201:3 Database) Page 5 Copyright © by Leong Hon Wai Normal Operations (1/2) Bank-Account-DB Withdraw-P(1000);Deposit-P(2000); TWTW TDTD Time Withdraw-P(1000) Deposit(2000) Balance TWTW Check balance [5000]5000 T W +1Bal  Bal – TDTD Check balance [4000]4000 T D +1Bal  Bal If (T W < T D ), then Correct balance

LeongHW, SOC, NUS (UIT2201:3 Database) Page 6 Copyright © by Leong Hon Wai Normal Operations (2/2) Bank-Account-DB Withdraw-P(1000);Deposit-P(2000); TWTW TDTD Time Withdraw-P(1000) Deposit(2000) Balance TDTD Check balance [5000]5000 T D +1Bal  Bal TWTW Check balance [7000]7000 T W +1Bal  Bal – If (T W > T D ), then Correct balance

LeongHW, SOC, NUS (UIT2201:3 Database) Page 7 Copyright © by Leong Hon Wai Concurrency Issue (1/4) But… What if two processes accesses the same database record at the same time?  Which process get access first?  Does it matter?

LeongHW, SOC, NUS (UIT2201:3 Database) Page 8 Copyright © by Leong Hon Wai Concurrency Problem (2/4) Bank-Account-DB Withdraw-P(1000);Deposit-P(2000); TWTW TDTD Time Withdraw-P(1000) Deposit(2000) Balance TDTD Check balance [5000]5000 T D +1Check balance [5000]5000 T D +2 Bal  Bal T D +3Bal  Bal – If (T W = T D ), and Deposit-process “got in” first Wrong balance

LeongHW, SOC, NUS (UIT2201:3 Database) Page 9 Copyright © by Leong Hon Wai Concurrency Problem (2/3) Bank-Account-DB Withdraw-P(1000);Deposit-P(2000); TWTW TDTD Time Withdraw-P(1000) Deposit(2000) Balance TWTW Check balance [5000]5000 T W +1 Check balance [5000]5000 T W +2Bal  Bal – T W +3Bal  Bal If (T W = T D ), and Withdraw-process “got in” first Wrong balance

LeongHW, SOC, NUS (UIT2201:3 Database) Page 10 Copyright © by Leong Hon Wai Concurrency Problem (3/3)  Operations of the two processes are interleaved  Withdraw-Process and Deposit-Process “interfere” with each other  Wrong balance for both cases  Since one of the operations is over-written

LeongHW, SOC, NUS (UIT2201:3 Database) Page 11 Copyright © by Leong Hon Wai Concurrency Solution: Lock operation IDEA: If one process P is changing balance, make sure that other processes do not access the same balance until P is done Solution: The process that “get-in” first, locks up the record. This makes sure other processes will not be to access the same record. Unlock the record after update is done.

LeongHW, SOC, NUS (UIT2201:3 Database) Page 12 Copyright © by Leong Hon Wai Concurrency Solution: (2/4) Withdraw-P (amt); begin Get & lock record; bal  bal - amt; unlock record; end; Deposit-P (amt); begin Get & lock record; bal  bal + amt; unlock record; end;  Deposit and Withdrawal Processes Bank-Account-DB

LeongHW, SOC, NUS (UIT2201:3 Database) Page 13 Copyright © by Leong Hon Wai Concurrency Solution: (3/4) Bank-Account-DB Withdraw-P(1000);Deposit-P(2000); TWTW TDTD Time Withdraw-P(1000) Deposit(2000) Balance TWTW Get & Lock record;5000 T W +1 Get...; [blocked]5000 T W +2Bal  Bal – 1000; Unlock record; 4000 T W +3Get & Lock record;4000 T W +4Bal  Bal ; Unlock record; 6000 If (T W = T D ), and Withdraw-process “got in” first

LeongHW, SOC, NUS (UIT2201:3 Database) Page 14 Copyright © by Leong Hon Wai Concurrency Solution: (4/4) Bank-Account-DB Withdraw-P(1000);Deposit-P(2000); TWTW TDTD Time Withdraw-P(1000) Deposit(2000) Balance TWTW Get & Lock record;5000 T W +1Get...; [blocked]5000 T W +2Bal  Bal ; Unlock record; 7000 T W +3Get & Lock record;7000 T W +4Bal  Bal – 1000; Unlock record; 6000 If (T W = T D ), and Deposit-process “got in” first

LeongHW, SOC, NUS (UIT2201:3 Database) Page 15 Copyright © by Leong Hon Wai … Case Study: The ATM Machine

LeongHW, SOC, NUS (UIT2201:3 Database) Page 16 Copyright © by Leong Hon Wai Simple ATM Scenario (1 of 2) Bank User ATM Machine Bank HQ Inserts ATM card Prompt for PIN # Enter the PIN # Send encoded Acct #, PIN # Send encoded Verified Msg Display Options Choose (Withdraw $100) [Verifies A/C # & Pin #] [Reads card] [encode] network

LeongHW, SOC, NUS (UIT2201:3 Database) Page 17 Copyright © by Leong Hon Wai Simple ATM Scenario (2 of 2) Bank User ATM Machine Bank HQ [Verifies balance] [Deduct $100] User collects $100 Send request (W,100) Send Verified Msg Display and Print new Bal Chooses (Withdraw $100) [Counts out $100] Send ack of withdrawal [encode] network

LeongHW, SOC, NUS (UIT2201:3 Database) Page 18 Copyright © by Leong Hon Wai … What if something goes wrong?

LeongHW, SOC, NUS (UIT2201:3 Database) Page 19 Copyright © by Leong Hon Wai Simple ATM Scenario: Malfunction Bank User ATM Machine Bank HQ Inserts ATM card Prompt for PIN # Enter the PIN # Send encoded Acct #, PIN # Send encoded Verified Msg Display Options Choose (Withdraw $100) [Verifies A/C # & Pin #] [Reads card] [encode] network What if something goes wrong?

LeongHW, SOC, NUS (UIT2201:3 Database) Page 20 Copyright © by Leong Hon Wai Simple ATM Scenario: Malfunction… Bank User ATM Machine Bank HQ [Verifies balance] [Deduct $100] User collects $100 Send request (W,100) Send Verified Msg Display and Print new Bal Chooses (Withdraw $100) [Counts out $100] Send ack of withdrawal [encode] network What if something goes wrong?

LeongHW, SOC, NUS (UIT2201:3 Database) Page 21 Copyright © by Leong Hon Wai Actually, no technical solution…

LeongHW, SOC, NUS (UIT2201:3 Database) Page 22 Copyright © by Leong Hon Wai What to modify/add for future…  Value added Services:  Data Mining – frequent patterns  Targeted marketing (Database marketing)  Credit-card fraud,  Handphone acct churning analysis

LeongHW, SOC, NUS (UIT2201:3 Database) Page 23 Copyright © by Leong Hon Wai Topic Summary: Database  Databases: what they are, organization, etc  Database Query:  How query is processed “under the hood”  3 basic DB primitives  Impetus for “Declarative Style of Query”  Concurrency Issues in Databases  How to deal with Concurrency  The ATM Case Study  Database Applications…

LeongHW, SOC, NUS (UIT2201:3 Database) Page 24 Copyright © by Leong Hon Wai Thank you!

LeongHW, SOC, NUS (UIT2201:3 Database) Page 25 Copyright © by Leong Hon Wai