35
Managing Multi-User Databases. Concurrency, Security & Integrity

Multi Concurency Secint

Embed Size (px)

DESCRIPTION

kjhgf mjjhajgds aksjhdbsajgf sasjhdgbsjh askjhdshkjabdgas aghsjdsgafd ashkgdsute aukgfb ksafa

Citation preview

  • Managing Multi-User Databases.Concurrency, Security & Integrity

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Components of a DBMS

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Database AdministrationAll large and small databases need database administrationData administration refers to a function concerning all of an organizations data assetsDatabase administration (DBA) refers to a person or office specific to a single database and its applications

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    DBA TasksManaging database structureControlling concurrent processingManaging processing rights and responsibilitiesDeveloping database securityProviding for database recoveryManaging the DBMSMaintaining the data repository

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Managing Database StructureDBAs tasks:Participate in database and application developmentAssist in requirements stage and data model creationPlay an active role in database design and creationFacilitate changes to database structureSeek community-wide solutionsAssess impact on all usersProvide configuration control forumBe prepared for problems after changes are madeMaintain documentation

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Concurrency ControlConcurrency control ensures that one users work does not inappropriately influence another users workNo single concurrency control technique is ideal for all circumstancesTrade-offs need to be made between level of protection and throughput

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Atomic TransactionsA transaction, or logical unit of work (LUW), is a series of actions taken against the database that occurs as an atomic unitEither all actions in a transaction occur or none of them do

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Example: Atomic Transaction

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Example: Atomic Transaction

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Concurrent TransactionConcurrent transactions refer to two or more transactions that appear to users as they are being processed against a database at the same timeIn reality, CPU can execute only one instruction at a timeTransactions are interleaved meaning that the operating system quickly switches CPU services among tasks so that some portion of each of them is carried out in a given intervalConcurrency problems: lost update and inconsistent reads

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Example: Concurrent Transactions

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Example: Lost Update Problem

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Resource LockingResource locking prevents multiple applications from obtaining copies of the same record when the record is about to be changed

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Lock Terminology Implicit locks are locks placed by the DBMSExplicit locks are issued by the application programLock granularity refers to size of a locked resourceRows, page, table, and database levelLarge granularity is easy to manage but frequently causes conflictsTypes of lockAn exclusive lock prohibits other users from reading the locked resourceA shared lock allows other users to read the locked resource, but they cannot update it

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Example: Explicit Locks

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Deadlock Deadlock, or the deadly embrace, occurs when two transactions are each waiting on a resource that the other transaction holds

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Example: Deadlock

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    DeadlockPreventing deadlockAllow users to issue all lock requests at one timeRequire all application programs to lock resources in the same orderBreaking deadlockAlmost every DBMS has algorithms for detecting deadlockWhen deadlock occurs, DBMS aborts one of the transactions and rollbacks partially completed work

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Declaring Lock CharacteristicsMost application programs do not explicitly declare locks due to its complicationInstead, they mark transaction boundaries and declare locking behavior they want the DBMS to useTransaction boundary markers: BEGIN, COMMIT, and ROLLBACK TRANSACTIONAdvantageIf the locking behavior needs to be changed, only the lock declaration need be changed, not the application program

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Example: Marking Transaction Boundaries

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Database SecurityDatabase security ensures that only authorized users can perform authorized activities at authorized timesDeveloping database securityDetermine users processing rights and responsibilities Enforce security requirements using security features from both DBMS and application programs

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    DBMS SecurityDBMS products provide security facilities They limit certain actions on certain objects to certain users or groupsAlmost all DBMS products use some form of user name and password security

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    DBMS Security Model

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    DBMS Security GuidelinesRun DBMS behind a firewall, but plan as though the firewall has been breachedApply the latest operating system and DBMS service packs and fixesUse the least functionality possibleSupport the fewest network protocols possibleDelete unnecessary or unused system stored proceduresDisable default logins and guest users, if possibleUnless required, never allow all users to log on to the DBMS interactivelyProtect the computer that runs the DBMSNo user allowed to work at the computer that runs the DBMSDBMS computer physically secured behind locked doorsAccess to the room containing the DBMS computer should be recorded in a log

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    DBMS Security Guidelines (cont.)Manage accounts and passwordsUse a low privilege user account for the DBMS serviceProtect database accounts with strong passwordsMonitor failed login attemptsFrequently check group and role membershipsAudit accounts with null passwordsAssign accounts the lowest privileges possibleLimit DBA account privilegesPlanningDevelop a security plan for preventing and detecting security problemsCreate procedures for security emergencies and practice them

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Application SecurityIf DBMS security features are inadequate, additional security code could be written in application programApplication security in Internet applications is often provided on the Web server computerHowever, you should use the DBMS security features firstThe closer the security enforcement is to the data, the less chance there is for infiltrationDBMS security features are faster, cheaper, and probably result in higher quality results than developing your own

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Database RecoveryIn the event of system failure, that database must be restored to a usable state as soon as possibleTwo recovery techniques: Recovery via reprocessingRecovery via rollback/rollforward

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Recovery via ReprocessingRecovery via reprocessing: the database goes back to a known point (database save) and reprocesses the workload from there (re-execute all database update programs)Unfeasible strategy becauseThe recovered system may never catch up if the computer is heavily scheduledAsynchronous events, although concurrent transactions, may cause different results

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Rollback/Rollforward Recovery via rollback/rollforward: Periodically save the database and keep a database change log since the saveDatabase log contains records of the data changes in chronological orderWhen there is a failure, either rollback or rollforward is appliedRollback: undo the erroneous changes made to the database and reprocess valid transactionsRollforward: restored database using saved data and valid transactions since the last save

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Example: RollbackBefore-images: a copy of every database record (or page) before it was changed

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Example: RollforwardAfter-images: a copy of every database record (or page) after it was changed

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Example: Transaction Log

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    CheckpointA checkpoint is a point of synchronization between the database and the transaction logDBMS refuses new requests, finishes processing outstanding requests, and writes its buffers to diskThe DBMS waits until the writing is successfully completed the log and the database are synchronizedCheckpoints speed up database recovery processDatabase can be recovered using after-images since the last checkpointCheckpoint can be done several times per hourMost DBMS products automatically checkpoint themselves

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Managing the DBMSDBAs ResponsibilitiesGenerate database application performance reportsInvestigate user performance complaintsAssess need for changes in database structure or application designModify database structureEvaluate and implement new DBMS featuresTune the DBMS

    Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

    Maintaining the Data RepositoryDBA is responsible for maintaining the data repositoryData repositories are collections of metadata about users, databases, and its applicationsThe repository may be Virtual as it is composed of metadata from many different sources: DBMS, code libraries, Web page generation and editing tools, etc.An integrated product from a CASE tool vendor or from other companiesThe best repositories are active and they are part of the system development process