DOC PREVIEW
UMD CMSC 424 - Lecture 2

This preview shows page 1-2-17-18-19-35-36 out of 36 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CMSC424: Database DesignAdministrativeTodayExampleA file-system based solutionSlide 6What’s wrong with this solution ?Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15How ?Data AbstractionSlide 18Data Abstraction: Banking ExampleSlide 20DBMS at a GlanceData ModelingData RetrievalData StorageData IntegritySlide 26DBMS at a glanceRecapSlide 29MotivationDatabase Design StepsEntity-Relationship ModelSlide 33ER Diagram: Starting ExampleRest of the classNext: Relationship CardinalitiesCMSC424: Database DesignInstructor: Amol Deshpande [email protected]Homework 1 out today.Laptops.Email to me: write CMSC424 in the title.TodayData management challenges in a very simple applicationWhy we can’t use a file system to do database managementData ModellingGoing from conceptual requirements of a application to a concrete data modelExampleSimple Banking ApplicationNeed to store information about:AccountsCustomersNeed to support:ATM transactionsQueries about the dataInstructive to see how a naïve solution will workA file-system based solutionData stored in files in ASCII format #-seperated files in /usr/db directory/usr/db/accounts Account Number # Balance 101 # 900 102 # 700 …/usr/db/customers Customer Name # Customer Address # Account Number Johnson # 101 University Blvd # 101 Smith # 1300 K St # 102 Johnson # 101 University Blvd # 103 …A file-system based solutionWrite application programs to support the operationsIn your favorite programming languageTo support withdrawals by a customer for amount $X from account YScan /usr/db/accounts, and look for Y in the 1st fieldSubtract $X from the 2nd field, and rewrite the fileTo support finding names of all customers on street ZScan /usr/db/customers, and look for (partial) matches for Z in the addess field…What’s wrong with this solution ?1. Data redundancy and inconsistencyNo control of redundancyCustomer Name # Customer Address # Account Number Johnson # 101 University Blvd # 101 Smith # 1300 K St # 102 Johnson # 101 University Blvd # 103 …Especially true when programs/data organization evolve over timeInconsistenciesData in different files may not agree Very critical issueWhat’s wrong with this solution ?2. Evolution of the database is hardDelete an accountWill have to rewrite the entire fileAdd a new field to the accounts file, or split the customers file in two parts:Rewriting the entire file least of the worriesWill probably have to rewrite all the application programsWhat’s wrong with this solution ?3. Difficulties in Data RetrievalNo sophisticated tools for selective data accessAccess only the data for customer XInefficient to scan the entire fileLimited reuseFind customers who live in area code 301Unfortunately, no application program already writtenWrite a new program every time ?What’s wrong with this solution ?4. Semantic constraintsSemantic integrity constraints become part of program codeBalance should not fall below 0Every program that modifies the balance will have to enforce this constraintHard to add new constraints or change existing onesBalance should not fall below 0 unless overdraft-protection enabledNow what? Rewrite every program that modifies the balance ?What’s wrong with this solution ?5. Atomicity problems because of failuresJim transfers $100 from Acct #55 to Acct #3761. Get balance for acct #552. If balance55 > $100 then a. balance55 := balance55 - 100 b. update balance55 on disk c. get balance from database for acct #376 d. balance376 := balance376 + 100 e. update balance376 on diskCRASHMust be atomic Do all the operations or none of the operationsWhat’s wrong with this solution ?6. Durability problems because of failuresJim transfers $100 from Acct #55 to Acct #3761. Get balance for acct #552. If balance55 > $100 then a. balance55 := balance55 - 100 b. update balance55 on disk c. get balance from database for acct #376 d. balance376 := balance376 + 100 e. update balance376 on disk f. print receiptCRASHAfter reporting success to the user, the changesbetter be there when he checks tomorrowWhat’s wrong with this solution ?7. Concurrent access anomaliesJoe@ATM1: Withdraws $100 from Acct #55 1. Get balance for acct #55 2. If balance55 > $100 thena. balance55 := balance55 – 100b. dispense cashc. update balance55Jane@ATM2: Withdraws $50 from Acct #55 1. Get balance for acct #55 2. If balance55 > $50 thena. balance55 := balance55 – 50b. dispense cashc. update balance55What’s wrong with this solution ?7. Concurrent access anomaliesJoe@ATM1: Withdraws $100 from Acct #55 1. Get balance for acct #55 2. If balance55 > $100 thena. balance55 := balance55 – 100b. dispense cashc. update balance55Jane@ATM2: Withdraws $50 from Acct #55 1. Get balance for acct #55 2. If balance55 > $50 thena. balance55 := balance55 – 50b. dispense cashc. update balance55Balance would only reflect one of the two operations Bank loses moneyWhat’s wrong with this solution ?8. Security IssuesNeed fine grained control on who sees whatOnly the manager should have access to accounts with balance more than $100,000How do you enforce that if there is only one accounts file ? Database management provide an end-to-end solution to all of these problemsHow ?The key insight is whats called data abstractionData AbstractionProbably the most important purpose of a DBMSGoal: Hiding low-level details from the users of the systemThrough use of logical abstractionsData AbstractionLogicalLevelPhysical LevelView LevelView 1 View 2 View n…How data is actually stored ? e.g. are we using disks ? Which file system ?What data is stored ? describe data properties such as data semantics, data relationshipsWhat data users and application programs see ?Data Abstraction: Banking ExampleLogical level:Provide an abstraction of tablesTwo tables can be accessed:accountsColumns: account number, balancecustomersColumns: name, address, account numberView level:A teller (non-manager) can only see a part of the accounts tableNot containing high balance accountsData Abstraction: Banking ExamplePhysical Level:Each table is stored in a separate ASCII file# separated fieldsIdentical to what we had before ?BUT the users are not aware of


View Full Document

UMD CMSC 424 - Lecture 2

Documents in this Course
Databases

Databases

44 pages

Load more
Download Lecture 2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 2 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?