Presentation is loading. Please wait.

Presentation is loading. Please wait.

Security, Transactions, and Views. About Security As is the case in most shared environments, the DBMS also must implement a security mechanism that allows.

Similar presentations


Presentation on theme: "Security, Transactions, and Views. About Security As is the case in most shared environments, the DBMS also must implement a security mechanism that allows."— Presentation transcript:

1 Security, Transactions, and Views

2 About Security As is the case in most shared environments, the DBMS also must implement a security mechanism that allows the setting of permissions to data and actions pertaining to that data. This is required to ensure data security.

3 Security Achieved through GRANT & REVOKEAchieved through GRANT & REVOKE Assumes the database can recognize its users and verify their identityAssumes the database can recognize its users and verify their identity can also be controlled through the use of views - subsets of datacan also be controlled through the use of views - subsets of data usually maintained by the database administrator or DBAusually maintained by the database administrator or DBA

4 GRANT Command This “grants” a user or group of users permission to manipulate specified data in specified ways. GRANT {ALL | privilege_list} ON {table_name | view_name [(col_list)]} TO {PUBLIC | user_list} GRANT {ALL | privilege_list} ON {table_name | view_name [(col_list)]} TO {PUBLIC | user_list}

5 REVOKE Command This “revokes” a granted permission issued by GRANT from a specified user. REVOKE {ALL | privilege_list} ON {table_name | view_name [(col_list)]} FROM {PUBLIC | user_list} Tip: 1) You GRANT TO and REVOKE FROM. 2) The most recently issued statement supercedes all others.

6 Views A view is representation of an existing table which corresponds to the SELECT statement that created it. The view can then be manipulated much like an actual table. A view is not a separate table or entity. It’s more like a mask of the actual table.

7 Uses of a VIEW Hiding sensitive data from usersHiding sensitive data from users Preserving a previous table schemaPreserving a previous table schema Presenting data to users in a desired format.Presenting data to users in a desired format. Simplify a complex querySimplify a complex query

8 Creating a VIEW CREATE VIEW view_name [(col_name…)] AS SELECT _statement

9 Dropping a VIEW DROP VIEW view_name Only drops the view… not the table.

10 More about Views The view displays like any table and the data you see is the actual data in the table(s).The view displays like any table and the data you see is the actual data in the table(s). A view is more for viewing rather than updating since an update could disqualify a record from the view.A view is more for viewing rather than updating since an update could disqualify a record from the view. Updates made to a view are made to the table(s) and any changes made to the table(s) are reflected in the view.Updates made to a view are made to the table(s) and any changes made to the table(s) are reflected in the view.

11 Naming View Columns Column names are inherited from the underlying tables.Column names are inherited from the underlying tables. New names can be assignedNew names can be assigned Columns must be renamed when using arithmetic expressions or when more than one column has the same name.Columns must be renamed when using arithmetic expressions or when more than one column has the same name.

12 Transactions are... Transaction - Logical unit of work Transaction Management - ensuring that a set of SQL statements is treated as a unit - an indivisible entity

13 Transactions A transaction is a set of SQL statements that represent a unit of work or a procedural operation. A transaction is not complete unless all off its steps are followed through. This can be critical to maintaining data integrity such as when an account must be credited while debiting another.

14 Why transactions? Transactions are necessary for the purpose of concurrency control and recovery concurrency control - allowing multiple users simultaneous access recovery - allowing the database system to return the database to a reliable state after a failure.

15 Concurrency Lost-update problemLost-update problem LockingLocking –database system puts a lock on accessed data so it cannot be altered until lock is released.

16 Locking Since many users may be trying to access the same data simultaneously the DBMS has a locking mechanism which locks data which is in use. This provides a solution to concurrency problems which would arise if locking were not available.

17 2 Types of Locks Exclusive - for UPDATE, INSERT, and DELETE (write operations) - no other transaction can acquire lock until original is released Shared - applied during non-update or read operations - usually SELECT - prevents write operations from acquiring lock - allows other read operations to share lock

18 Recovery Allows a database to bounce back after a system failureAllows a database to bounce back after a system failure must decidemust decide –what transactions are incomplete –which transactions completed but were not written and must be redone

19 User-defined Transactions Allows user to define any number of SQL statements as a transaction and instruct the database to process them as one unit.Allows user to define any number of SQL statements as a transaction and instruct the database to process them as one unit.

20 Defining a Transaction A transaction starts with the keyword BEGINA transaction starts with the keyword BEGIN BEGIN SQL statement SQL statement SQL statement COMMIT

21 Finishing the Transaction If the transaction goes successfully then the COMMIT command will commit the changes to the database.If the transaction goes successfully then the COMMIT command will commit the changes to the database. However, if an error occurs the ROLLBACK command can be used to restore the database to its state prior to the transaction.However, if an error occurs the ROLLBACK command can be used to restore the database to its state prior to the transaction.


Download ppt "Security, Transactions, and Views. About Security As is the case in most shared environments, the DBMS also must implement a security mechanism that allows."

Similar presentations


Ads by Google