IMPLEMENTING TRANSACTION AND SECURITY doc

40 140 0
  • Loading ...
    Loading ...
    Loading ...

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Tài liệu liên quan

Thông tin tài liệu

Ngày đăng: 01/08/2014, 09:21

3B.1 Relational Database Desi g n L L E E S S S S O O N N : : 3 3 B B I I M M P P L L E E M M E E N N T T I I N N G G T T R R A A N N S S A A C C T T I I O O N N A A N N D D S S E E C C U U R R I I T T Y Y O O b b j j e e c c t t i i v v e e s s In this section, you will learn to:  Describe Transaction Processing  Describe Transaction Recovery  Define Transaction Log  Identify the Concurrency Problems  Identify the Types of Locks  Define a Deadlock  Describe the Security Scheme Concepts  Establish the Security Scheme 3B.2 Relational Database Desi g n Implementing Transaction and Security Lesson 3B / Slide 1 of 25©NIIT Implementing Transaction and Security Objectives In this section, you will learn to: • Describe Transaction processing • Describe Transaction Recovery • Define Transaction Log • Identify the Concurrency Problems • Identify the Types of Locks • Define a Deadlock • Describe the Security Scheme Concepts • Establish the Security Scheme I I N N S S T T R R U U C C T T O O R R N N O O T T E E S S Lesson Overview The lesson introduces the concept of transaction processing, transaction recovery, and transaction log. This lesson also describes concurrency problems that can occur in a database and explains locking as a technique to avoid concurrency problems. In addition, this lesson identifies the various security schemes and explains how to establish a security scheme. 3B.3 Relational Database Desi g n Implementing Transaction and Security Lesson 3B / Slide 2 of 25©NIIT Implementing Transaction and Security Pre-assessment Questions 1. Which SQL statements are used to create and delete tables? a. DDL b. DQL c. DML d. DCL 2. A _____ is a named, derived, virtual table that does not exist physically. a. Source table b. Query c. View d. Base table 3. Which type of view includes all rows but only some columns of the source table? a. Joined b. Column subset c. Grouped d. Row subset 3B.4 Relational Database Desi g n Implementing Transaction and Security Lesson 3B / Slide 3 of 25©NIIT Implementing Transaction and Security Pre-assessment Questions (Contd ) 4. Which data integrity constraint requires that a column contain a non-null value? a. Entity integrity b. Referential integrity c. Business rules d. Required data 5. For any event that causes a change in the contents of a table, a user can specify an associated action that the DBMS should carry out. What is this action called? a. Log b. Trigger c. Integrity d. Relation 3B.5 Relational Database Desi g n Implementing Transaction and Security Lesson 3B / Slide 4 of 25©NIIT Implementing Transaction and Security Solutions Ans1. DDL Ans2. View Ans3. Column subset Ans4. Required data Ans5. Trigger 3B.6 Relational Database Desi g n D D A A T T A A B B A A S S E E T T R R A A N N S S A A C C T T I I O O N N P P R R O O C C E E S S S S I I N N G G Implementing Transaction and Security Lesson 3B / Slide 5 of 25©NIIT Implementing Transaction and Security Database Transaction Processing • A transaction is a sequence of one or more SQL statements that together form a logical unit of work. • All the statements that constitute a transaction must be executed to maintain consistency of the database. • The DBMS is responsible for ensuring consistency of the database. This holds true even if the application program aborts or a hardware failure occurs in the middle of a transaction. • The DBMS must never allow a partial transaction. • To maintain consistency, the DBMS undoes all the changes made by an incomplete transaction. A transaction is a sequence of one or more SQL statements that together form a logical unit of work. Each statement in a transaction performs a part of the task and all the statements together complete the task. A transaction occurs when a database is modified. All the statements that constitute a transaction must be executed to maintain consistency of the database. Let us consider an example of a typical transaction. A student orders for a book. The order processing program will: Query the table that contains the details of the books to check if the book is available. Insert the order details into a table that holds the order details. 3B.7 Relational Database Desi g n Update the table containing product details to reduce the quantity on hand by the quantity ordered. These three actions in the above sequence form a single logical transaction. The concept of transaction processing is critical for programs that update a database because it ensures the integrity of the database. As a rule, the statements in a transaction are executed as a single unit of work in the database. Either all the statements will be executed successfully, or none of the statements will be executed. The DBMS is responsible for ensuring consistency of the database. This holds true even if the application program aborts or a hardware failure occurs in the middle of a transaction. The DBMS must never allow a partial transaction. Consider the above example of a transaction. If the order processing program aborts after the second step, the database would reflect a partial transaction and be in an inconsistent state. To maintain consistency, the DBMS undoes all the changes made by an incomplete transaction as shown in the following figure. Therefore, a DBMS guarantees that if a transaction executes some updates and a failure occurs before completing the transaction, the updates are undone. 3B.8 Relational Database Desi g n SELECT UPDATE UPDATE DELETE Program Error! DBMS undoes all changes Transaction The SQL Transaction Concept SELECT UPDATE UPDATE DELETE INSERT Database state after transaction Database state before transaction SELECT UPDATE Hardware Failure DBMS undoes all changes 3B.9 Relational Database Desi g n Transaction Recovery Implementing Transaction and Security Lesson 3B / Slide 6 of 25©NIIT Implementing Transaction and Security Transaction Recovery • The two SQL operations that support transaction processing are: • COMMIT operation • ROLLBACK operation The two SQL operations that support transaction processing are:  The COMMIT operation This signifies a successful end-of-transaction. It confirms the DBMS that a logical unit of work has been successfully completed. The database is consistent and all updates made by the transaction have been committed or made permanent. The ROLLBACK operation This signals an unsuccessful end-of-transaction. It specifies that there has been a failure and the database is inconsistent. All updates made by the transaction till the point of failure must be rolled back or undone. 3B.10 Relational Database Desi g n Transaction Log Implementing Transaction and Security Lesson 3B / Slide 7 of 25©NIIT Implementing Transaction and Security Transaction Log • To undo the changes made to a database, the DBMS maintains a transaction log. • The transaction log tracks all the transactions made. • When a user executes a SQL statement that modifies the database, the DBMS writes a record in the transaction log. • The transaction log displays the following two copies of each row affected by the statement. One copy displays the row before the statement was executed and the other copy displays the row with the changes. • If the user executes a commit, the end-of-transaction is noted in the transaction log. If the user executes a ROLLBACK, the DBMS examines the log to find the copy of the rows before the change. To undo the changes made to a database, the DBMS maintains a transaction log. The transaction log tracks all the transactions made. When a user executes a SQL statement that modifies the database, the DBMS actually writes a record in the transaction log. The transaction log displays two copies of each row affected by the statement. One copy displays the row before the statement was executed and the other copy displays the row with the changes. The DBMS modifies the row on the disk only after the log is written. If the user executes a commit, the end-of-transaction is noted in the transaction log. If the user executes a ROLLBACK, the DBMS examines the log to find the copy of the rows before the change. Using this, the DBMS restores the database to its earlier state, undoing all changes made during the transaction. The following figure illustrates the way in which the transaction log works in an RDBMS. [...]... automatically revoked Views and Security Implementing Transaction and Security Views and Security • • • ©NIIT 3B.31 Views play a key role in security Views enable precise control over which data is made visible to the users If a view is created that comprises only some of the columns, the user’s access to the table is limited to only those columns defined in the view Implementing Transaction and Security Lesson... Establishing the Security Scheme Implementing Transaction and Security Establishing the Security Scheme • • ©NIIT A security scheme for a database can be established using the SQL statements: • GRANT • REVOKE In order to perform any operation on a database, a user must have the appropriate authority for that operation Implementing Transaction and Security Lesson 3B / Slide 17 of 25 A security scheme... ROLLBACK operation • To undo the changes made to a database, the DBMS maintains a transaction log The transaction log tracks all the transactions made ©NIIT Implementing Transaction and Security Relational Database Design Lesson 3B / Slide 22 of 25 3B.34 Implementing Transaction and Security Summary (Contd ) • • • ©NIIT 3B.35 Transaction processing is complicated in multi-user systems There are three problems... released 3B.17 Relational Database Design If transaction A holds a shared lock on some data and transaction B requests for an exclusive lock on the same data, transaction B will have to wait until transaction A’s lock is released If transaction A holds a shared lock and transaction B also requests for a shared lock, transaction B’s request will be granted Both the transactions will hold shared locks on the... periodically checks the locks held by various transactions When it detects a deadlock, the DBMS chooses one of the transactions as the deadlock loser and rolls back that transaction It releases the lock held by the transaction and allows the other transaction to proceed The losing transaction receives an error message, informing that it has lost the deadlock, and its transactions have been rolled back If a... periodically checks the locks held by various transactions When it detects a deadlock, the DBMS chooses one of the transactions as the deadlock loser and rolls back that transaction It releases the lock held by the transaction and allows the other transaction to proceed The losing transaction receives an error message, informing that it has lost the deadlock, and its transactions have been rolled back This... allowed to view and retrieve data For some tables, access should be restricted on a column-by-column basis Selected users should only be allowed to access tables using application programs Enforcing security restrictions is a responsibility of the DBMS 3B.21 Relational Database Design Security Scheme Concepts Implementing Transaction and Security Security Scheme Concepts • ©NIIT The security scheme... users and prevented from others Implementing Transaction and Security Lesson 3B / Slide 15 of 25 Security restrictions apply to specific objects in a database The objects to which security can be applied are: Tables Views Relational Database Design 3B.24 Each table or view can be individually protected Access to a table or view can be permitted to some users and prevented from others Privileges Implementing. .. transactions Implementing Transaction and Security Lesson 3B / Slide 9 of 25 When a transaction needs to be sure that a particular database object must not change unpredictably while it is not aware of such a change happening, it acquires a lock The effect of this lock is to lock all other transactions out, and thus prevent them from changing the database object The first transaction will process the object and. .. Design 3B.28 Passing Privileges Implementing Transaction and Security Passing Privileges • • ©NIIT You can grant a privilege to another user and allow the user to pass the privilege to other users In SQL, this is done through the WITH GRANT OPTION of the GRANT statement as: GRANT ON TO WITH GRANT OPTION Implementing Transaction and Security Lesson 3B / Slide 19 of . Desi g n Transaction Recovery Implementing Transaction and Security Lesson 3B / Slide 6 of 25©NIIT Implementing Transaction and Security Transaction Recovery • The two SQL operations that support transaction. Desi g n D D A A T T A A B B A A S S E E T T R R A A N N S S A A C C T T I I O O N N P P R R O O C C E E S S S S I I N N G G Implementing Transaction and Security Lesson 3B / Slide 5 of 25©NIIT Implementing Transaction and Security Database Transaction Processing • A transaction is a sequence. the Security Scheme Concepts  Establish the Security Scheme 3B.2 Relational Database Desi g n Implementing Transaction and Security Lesson 3B / Slide 1 of 25©NIIT Implementing Transaction and
- Xem thêm -

Xem thêm: IMPLEMENTING TRANSACTION AND SECURITY doc, IMPLEMENTING TRANSACTION AND SECURITY doc, IMPLEMENTING TRANSACTION AND SECURITY doc