Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Function

1,545 views

Published on

DBMS CJ Date-Function

Published in: Education
  • Be the first to comment

Function

  1. 1. Functions of a Database Management System
  2. 2. Functions of a DBMS C.J. DateIndexing Backup/RecoveryViews DesignSecurity DocumentationIntegrity Update/QueryConcurrency
  3. 3. Views Custom representations of adatabase that correspond to the needs of a class of users. Stored SELECT statements.
  4. 4. ViewsViews Provide: representations ofdata for different users to• protect data quality• insulate users from changes in structureCREATE VIEW VIEWNAME {VIEW ATTRIBUTES} AS (SELECT ..WHERE ..)
  5. 5. ViewsViews Permit Maintaining a constant user interface Restricting access to specified attributes Specifying user rights
  6. 6. Views 3 Schema Architecture User Views (Views or LOGICAL Queries) Database administratorsCONCEPTUAL model for the data (E-R diagrams) Actual data placement and PHYSICAL structure (SQL statements)
  7. 7. SecurityComponents that limit access or actions to limit potential damage to data.
  8. 8. SecurityLimit data access to properly authorizedusers or programs. Protect dataagainst accidental or intentionaldamage. • Deter • Detect • Minimize • Recover • Investigate
  9. 9. Security ApproachesViews limit access and actionsAuthorization Rules identify users andrestrict actionsUser Defined Procedures in additionto database security functionsEncryption encode stored dataAuthentication positively identify users
  10. 10. Authorization RulesSubject Object Action ConstraintSales Dept Cust Insert Credit < $5000Program Ar4 Order Modify NoneTerminal 12 Cust Modify Balance DueOrder Trans Cust Read None
  11. 11. Authorization RulesSome DBMS products authorize actionsbased on specific records and functionaldescriptions. However, most DBMS’s limitactions on tables to one of: • Read: view but not change • Insert: read and add records • Update: read, insert and change records • Alter/Delete: read, insert, update and delete records, change table structure
  12. 12. User Defined Procedures Code modules that enforce security procedures are run during processingUser DBMSProcedures Constraints DBMS
  13. 13. IntegrityComponents that preserve the relationship among differentrelated records in the database
  14. 14. IntegrityThe relationship among records in the database Referential Integrity Non Key Integrity Derived Conditions
  15. 15. Constraints in SQLCREATE TABLE … or ALTER TABLE … ADD CHECK(condition) PRIMARY KEY attribute-name FOREIGN KEY attribute-name REFERENCES parent-tableThe parent table must already have a primary key defined
  16. 16. Concurrency Preventing two users frominterfering with each other when they use the same information
  17. 17. ConcurrencyLockoutRestricting access to users who could be misled by partial transactionsVersioningMaking trial updates on versions of the database and denying one if there is a data conflict.
  18. 18. Locks Master Program 1 locks record Student Grade <exclusive>.00 Fred No other program can01 Anthony read the record. No program can have02 Steve an active lock.03 Ivan Program 2 locks record <shared> Other programs can read, but not change record. No program can have an exclusive lock.
  19. 19. LocksOn INSERT or UPDATE statementsSELECT column-namesFROM table-namesWHERE …FOR UPDATE OF column-namesNOWAIT;
  20. 20. Concurrency LocksGranularity Exclusivity• Field • Exclusive• Record • Shared• Table• Database
  21. 21. Concurrency DeadlockTwo programs request conflicting sets of data lock up the database while awaiting access. • Program 1 locks record A • Program 2 locks record B • Program 1 requests lock on record B; waits • Program 2 requests lock on record A; waitsSystem either times out and restarts each transaction after a random wait or recognizes the deadlock to abort one program.
  22. 22. Versioning Version 1 Time 1 Version 2 Version 3 Time 2 Time 3Commits version 3 only after changes to versions 1and 2 have been rolled back.
  23. 23. Backup and RecoveryProcesses to confirm and repeat transactions so that database can be restored to a valid state after a problem.
  24. 24. Backup and RecoveryBackup Copies• Master• Transaction LogJournalization• Forward Log• Backward LogCheckpoints
  25. 25. DBMS Logs Master Transaction Student Grade Insert Li with grade A00 Fred Change Fred’s grade to A01 Anthony02 Steve03 Ivan
  26. 26. Recover from Backup Transac- Backup + tion = Recovered DatabaseSlowMay give different answers from original
  27. 27. DBMS LogsTransaction Forward LogIns Li with grade A Student GradeChg Fred’s grade to A 03 Li A 00 Fred A Master Backward Log Student Grade Student Grade00 Fred A 03 n/p01 Anthony 00 Fred02 Steve03 Li A
  28. 28. DBMS LogsTransaction Forward LogIns Li with grade A Student GradeChg Fred’s grade to A 03 Li A10:00 Checkpoint 00 Fred A Chkpt Master Backward Log Student Grade Student Grade00 Fred A 03 n/p01 Anthony 00 Fred02 Steve Chkpt03 Li A
  29. 29. DBMS LogsTransaction Forward LogIns Li with grade A Student GradeChg Fred’s grade to A 03 Li A10:00 Checkpoint 00 Fred A ChkptChg Steve grade to B 02 Steve B Master Backward Log Student Grade Student Grade00 Fred A 03 n/p01 Anthony 00 Fred02 Steve B Chkpt03 Li A 02 Steve
  30. 30. Recover to Checkpoint Using Logs BackwardContaminated Database - Log = Correct at Checkpoint Recent + Transactions = Recovered Database
  31. 31. Transaction Processing A set of computer operations required to process a single unit of work.A transaction must conclude with the database in a valid state whether the transaction terminates correctly or abnormally
  32. 32. Transaction ProcessingTransaction Boundary• Locking Exclusive Shared• Logging Forward Backward Transaction• Modification Delete Insert Update• Commitment Commit Rollback
  33. 33. Transaction BoundariesSet Boundary• Obtain Locks• Execute Code Modules• Evaluate CorrectnessCommit or Rollback• Release Locks
  34. 34. Transaction BoundariesSet savepoint:SAVEPOINT order_save;Commit or rollback:ROLLBACK TO order_save;
  35. 35. Transaction Boundaries Premiere Products ExampleSALESREP CUSTOMER ORDERPRODUCT ORDER-PRODUCT Place an order for a new customer with a 1500 credit limit
  36. 36. Transaction Boundaries Premiere Products Example SALESREP CUSTOMER ORDER PRODUCT ORDER-PRODUCT•Insert CUSTOMER Record•Update CUSTOMER with SALESREP Foreign Key•Insert ORDER Record•Insert ORDER-PRODUCT with Foreign Keys•Update ProductOnHand in PRODUCT•Check Credit Limit
  37. 37. Transaction Processing Programming LogicTwo phased locking requires obtaining locks on all necessary records before releasing locks on any records. Obtain locks on all records needed Perform calculations Release locks
  38. 38. Functions of a DBMS C.J. DateIndexing Backup/RecoveryViews DesignSecurity DocumentationIntegrity Update/QueryConcurrency

×