Sunteți pe pagina 1din 10

2/14/13

Topic Transcript

Implementing Transaction Control and


Security
Learning Objectives

After completing this topic, you should be able to


describe transaction processing and concurrency control
describe concurrency control with locking
describe security concepts in a relational database
Exercise overview
In this exercise, you're required to recognize the basics of transaction processing and the ANSI/ISO model. You're
also required to understand the concurrency problems, locking mechanisms, and the security concepts available
in SQL.
This involves the following tasks:
recognizing transaction processing
recognizing how locks are used, and
recognizing security concepts in SQL

Recognizing transaction processing

Question
In multi-user DBMSs, it's important that transactions adhere to ACID properties to maintain data
integrity.
Match the descriptions with the appropriate property.
Options:
A. If a transaction fails when it is only partially complete, the entire transaction is rolled back
B. Variables should not be changed when a transaction is in progress
C. The data that a transaction acts on should remain the same until the transaction is
complete
D. Changes due to a successful transaction should be permanently stored in a database
Targets:
1. Atomicity
2. Consistency
3. Isolation
4. Durability

https://xlibrary.skillport.com/courseware/Content/cca/df_dbfn_a02_it_enus//output/t23/misc/transcript.html

1/10

2/14/13

Topic Transcript

Answer
Atomicity is a property of transactions which refers to all statements b eing executed successfully or
none b eing executed. So if a transaction fails when it is only partially complete, the entire
transaction is rolled b ack.
Consistency refers to variab les b eing consistent when a transaction is in progress. Other concurrent
transactions should not change the variab les until the current transaction is over.
Isolation refers to the availab ility of consistent data to an in-progress transaction. Updates from
other concurrent transactions should not b e availab le to the transaction.
Durab ility refers to the permanent availab ility of changes that are caused b y successful
transactions. Even if the hardware fails, the changes should b e availab le after system recovery.
Correct answer(s):

Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D

Question
How can you use transaction logs without affecting performance?
Options:
1. By storing transaction logs on a separate disk than where the data is stored
2. By storing only the original values in transaction logs
3. By disabling transaction logs for bulk updates
4. By disabling transaction logs for all transactions

Answer
Option 1: This option is correct. When transaction logs are used, additional system resources are
required to write to the log. So storing the transaction log on a separate disk than where the data is
stored will minimize disk retention.
Option 2: This option is incorrect. Transaction logs are used to store b oth the original and modified
values. The datab ase is only updated after the transaction log has b een updated with these values.
Option 3: This option is correct. Because a lot of values need to b e stored in the transaction log for
b ulk updates, the system overhead increases. So you can disab le transaction logs for b ulk
updates.
Option 4: This option is incorrect. System overhead will reduce if transaction logs are not used. But
you cannot disab le transaction logs for all transactions, b ecause they are required for rolling b ack
failed transactions and a loss of data will occur if they are not used.
Correct answer(s):
https://xlibrary.skillport.com/courseware/Content/cca/df_dbfn_a02_it_enus//output/t23/misc/transcript.html

2/10

2/14/13

Topic Transcript

1. By storing transaction logs on a separate disk than where the data is stored
3. By disabling transaction logs for bulk updates

Question
Identify the correct statements about savepoints.
Options:
1. They help to restart transactions from recoverable points
2. Multiple savepoints can be defined for each transaction
3. Savepoints help to define properties for the next transaction
4. A savepoint can only be released after the transaction ends

Answer
Option 1: This option is correct. A recoverab le point in a transaction is saved as a savepoint. When
the transaction rolls b ack, it can b e restarted from the recoverab le point rather than from the
b eginning.
Option 2: This option is correct. If a transaction can b e recovered and restarted from different
points, savepoints can b e created for each of these points.
Option 3: This option is incorrect. Savepoints cannot b e used to define the properties of
transactions. They can b e used to indicate recoverab le points in a transaction.
Option 4: This option is incorrect. A savepoint can b e released if it is no longer required b y a
transaction, even if the transaction is not complete. This releases the memory used b y the
savepoint.
Correct answer(s):
1. They help to restart transactions from recoverable points
2. Multiple savepoints can be defined for each transaction

Question
Identify the correct statements about implicit transactions.
Options:
1. All transactions in the ANSI/ISO model are implicit transactions
2. Any new statement is considered the beginning of a transaction
3. Client applications commonly use this type of transaction
4. Implicit transactions cannot be rolled back

Answer
https://xlibrary.skillport.com/courseware/Content/cca/df_dbfn_a02_it_enus//output/t23/misc/transcript.html

3/10

2/14/13

Topic Transcript

Option 1: This option is correct. In the ANSI/ISO model, transactions don't need to b e explicitly
started with the STARTTRANSACTIONstatement. So all transactions in this model are implicit. Any
DDL or DML statement that is run will automatically start a transaction. The transaction only ends
when a COMMITor ROLLBACKstatement is issued.
Option 2: This option is correct. In an implicit transaction, any SQL statement can b e used to b egin
a transaction. So when a new SQL statement is executed, it is considered the b eginning of a new
transaction.
Option 3: This option is incorrect. Though implicit transaction is the default in the SQL standard,
many client applications do not use this type of transactions. They usually use explicit transactions.
Option 4: This option is incorrect. If an implicit transaction cannot proceed b ecause of an error, it
can b e rolled b ack b y using the ROLLBACKstatement. Transactions cannot b e rolled b ack when
they are completed in the autocommit mode.
Correct answer(s):
1. All transactions in the ANSI/ISO model are implicit transactions
2. Any new statement is considered the beginning of a transaction

Question
How is the ROLLBACKstatement used in the ANSI/ISO model?
Options:
1. It is used to roll back transactions that were in progress when hardware failed
2. If an application ends normally, it is used to end the transaction that was in progress
3. A user can execute this statement to roll back a transaction
4. It can be used to roll back transactions in the autocommit mode

Answer
Option 1: This option is correct. Whenever a DBMS is restarted after hardware failure, all
transactions that were in progress at the time of failure are rolled b ack. The ROLLBACKstatement is
used for this purpose.
Option 2: This option is incorrect. If an application ends normally, the DBMS automatically issues
the COMMITstatement and commits the changes permanently to the datab ase.
Option 3: This option is correct. If a transaction fails, the user executing the transaction can end the
transaction b y issuing the ROLLBACKstatement. This restores the original values of data items to
the datab ase.
Option 4: This option is incorrect. In the autocommit mode, each statement is committed soon after
it is executed. So it is not possib le to roll b ack transactions.
Correct answer(s):
1. It is used to roll back transactions that were in progress when hardware failed
3. A user can execute this statement to roll back a transaction

https://xlibrary.skillport.com/courseware/Content/cca/df_dbfn_a02_it_enus//output/t23/misc/transcript.html

4/10

2/14/13

Topic Transcript

Question
Two transactions, A and B, are placing orders concurrently for the same product for their
customers. Ten products were available for sale before either transaction began.
Match the descriptions of issues with the concurrency problems.
Options:
A. A new product appears in the database while the transactions are in progress
B. Transaction A rejects an order for 10 products because only 5 are available. But it later
finds that 10 products are available
C. While transaction A updates the number of available products, transaction B commits its
update transaction and both transactions are committed
D. Transaction A finds 10 products are available initially. It runs the same query again only
to find that 5 products are available
Targets:
1. Phantom read
2. Dirty read
3. Lost update
4. Nonrepeatable read

Answer
The appearance of a new product indicates the phantom read prob lem. This prob lem occurs if a
transaction can access insertions from other transactions.
This represents the dirty read prob lem where transaction A accessed an uncommitted update b y
transaction B for 5 products. Transaction B later rolled the transaction b ack, returning the quantity
on hand to the original value.
This represents the lost update prob lem. When two transactions update the same data item, only
the update from the second committed transaction is availab le after b oth transactions are
committed. The update from the uncommitted transaction is lost and the incorrect numb er of items
are stated as availab le.
A nonrepeatab le read occurs when a transaction accesses updates b y other simultaneous
transactions. At different points during a transaction, a query yields different results.
Correct answer(s):

Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D

Recognizing how locks are used

https://xlibrary.skillport.com/courseware/Content/cca/df_dbfn_a02_it_enus//output/t23/misc/transcript.html

5/10

2/14/13

Topic Transcript

Question
Two transactions need to update the same data in a database.
How can a deadlock be avoided?
Options:
1. By defining the transactions to make updates in the same order
2. One of the transactions can be terminated if two transactions wait for each other to
release locks
3. By providing shared locks over the table to both of the transactions simultaneously
4. By granting exclusive locks over the table for both transactions simultaneously

Answer
Option 1: This option is correct. Transactions can b e deadlocked b y each other if the data item that
each needs to update is locked b y the other. If all similar transactions that need to update the same
data proceed in the same order, deadlocks can b e avoided.
Option 2: This option is incorrect. If two transactions wait for each other to release locks over data, a
deadlock has occurred. So terminating a transaction is not a measure to avoid deadlocks, though
DBMSs use this measure to manage deadlocks.
Option 3: This option is incorrect. Because a shared lock does not allow you to update data, and in
this case, b oth transactions need to update data, shared locks are not appropriate for these
transactions.
Option 4: This option is incorrect. Though transactions can update data with exclusive locks over
data, two transactions cannot ob tain exclusive locks over the same data simultaneously.
Correct answer(s):
1. By defining the transactions to make updates in the same order

Question
What statements about a DBMS that uses row level locks for both bulk updates and smaller
transactions are correct?
Options:
1. Bulk updates may be rolled back
2. The system overhead will increase
3. Both bulk updates and smaller transactions can proceed successfully
4. Bulk updates can be processed quickly

Answer
Option 1: This option is correct. If the data that a b ulk update wants to modify is locked b y another
transaction, a deadlock may occur. A b ulk update may b e terminated in such a case.
https://xlibrary.skillport.com/courseware/Content/cca/df_dbfn_a02_it_enus//output/t23/misc/transcript.html

6/10

2/14/13

Topic Transcript

Option 2: This option is correct. Because a b ulk update needs to update several rows, it may ob tain
locks over many rows. In such a situation, it b ecomes difficult for the DBMS to manage a high
numb er of locks, and the system overhead is increased.
Option 3: This option is incorrect. Using row level locks does not ensure that b oth transactions are
successful. Bulk updates and smaller transactions may need to update the same rows. In such a
case, deadlocks may occur, and one transaction may b e terminated.
Option 4: This option is incorrect. If row level locks are used, a b ulk update may b e forced to wait
for other smaller transactions to release locks over rows. But, if the b ulk update ob tains an explicit
lock over the tab le, it can b e processed quickly.
Correct answer(s):
1. Bulk updates may be rolled back
2. The system overhead will increase

Question
There are 10 products available for sale initially. And a few concurrent transactions processing
orders are in progress.
Match the descriptions with the isolation levels.
Options:
A. At any time during the course of a transaction, queries yield the same results
B. When a transaction executes a query again, though new products are listed, existing
data is unchanged
C. Though query results yield new and updated data, the lost update problem does not
occur
D. Insertions and updates by all other concurrent transactions are available in query results
Targets:
1. SERIALIZABLE
2. REPEATABLEREAD
3. READCOMMITTED
4. READUNCOMMITTED

Answer
The SERIALIZABLEisolation level is the highest level of isolation, in which each transaction
appears to happen in isolation. Changes b y other transactions are not availab le to the transaction.
In the REPEATABLEREADisolation level, data updates b y other committed or uncommitted
transactions are not availab le. However, insertions b y other transactions are indicated in query
results.
When the READCOMMITTEDisolation level is used, insertions and updates to data may b e
availab le. However, the data needed for a transaction will not b e modified b y other transactions.
READUNCOMMITTEDis the lowest level of isolation. Data updates and insertions from b oth
committed and uncommitted transactions are availab le for a transaction at this level.
https://xlibrary.skillport.com/courseware/Content/cca/df_dbfn_a02_it_enus//output/t23/misc/transcript.html

7/10

2/14/13

Topic Transcript

Correct answer(s):

Target 1 = Option A
Target 2 = Option B
Target 3 = Option C
Target 4 = Option D

Question
How can locking parameters be used to successfully carry out transactions?
Options:
1. Lock timeout can be defined for locks
2. A greater number of locks can be used if locks are escalated
3. Table level locks can be set for all transactions
4. The number of locks can be defined based on transaction complexity

Answer
Option 1: This option is correct. Specified time limits can b e defined for transactions to release the
locks. If locks are not released within this time limit, the DBMS will automatically release the locks.
Option 2: This option is incorrect. Lock escalation helps to reduce system overhead b y comb ining
several small locks into a single, large lock. However, it does not help to increase the numb er of
locks.
Option 3: This option is incorrect. Tab le level locks may not b e appropriate for all transactions. The
DBA can define specific lock sizes as required for transactions in addition to row, tab le, and page
level locks.
Option 4: This option is correct. The DBA can define the numb er of locks different transactions
require b ased on their complexity. Defining the numb er of locks also allows lock escalation.
Correct answer(s):
1. Lock timeout can be defined for locks
4. The number of locks can be defined based on transaction complexity

Recognizing relational database security

Question
Identify the statement that correctly describes user IDs and privileges.
Options:
https://xlibrary.skillport.com/courseware/Content/cca/df_dbfn_a02_it_enus//output/t23/misc/transcript.html

8/10

2/14/13

Topic Transcript

1. Managing user IDs is a complex process when user IDs are related to roles
2. It is easy to manage user IDs and track user actions if each user is given an individual
user ID
3. Having a single user ID for a group of users reduces traceability
4. A user who creates a view always has all of the privileges over that view

Answer
Option 1: This option is incorrect. Privileges are assigned to roles when roles are created. Then,
user IDs are related to necessary roles. This makes it easier to manage user IDs.
Option 2: This option is incorrect. When each user has an individual user ID, user actions can
easily b e traced. But, in such a situation, the DBA has to assign privileges to each user ID. This
makes management of user IDs complex.
Option 3: This option is correct. When multiple users can use the same user ID for their
transactions, actions can b e traced to a user ID. But the actions of individual users cannot b e
tracked.
Option 4: This option is incorrect. Views are created with data from either a single tab le or several
different tab les. The privileges over a view depend on the user's privileges over the tab les that the
views have b een created from.
Correct answer(s):
3. Having a single user ID for a group of users reduces traceability

Question
What does a DBA do to provide certain users of the organization with the privileges to access,
delete, insert, or modify data in a table?
Options:
1. Create and assign user IDs to users
2. Create views and grant privileges to them
3. Grant privileges to users
4. Deny privileges to users

Answer
Option 1: This option is correct. Identifying users with user IDs ensures that unauthorized users
cannot access the datab ase. So the DBA creates and assigns user IDs to ensure that only specific
users have privileges to access, delete, insert, or modify data.
Option 2: This option is incorrect. The DBA specifies that specific users can access, insert, delete, or
modify data in the tab le. However, the DBA does not create views to grant these privileges to
specific users.
Option 3: This option is correct. To allow specific users to insert, delete, modify, or access data from
the tab le, the DBA grants these privileges to the required users b y using the GRANTstatement.
https://xlibrary.skillport.com/courseware/Content/cca/df_dbfn_a02_it_enus//output/t23/misc/transcript.html

9/10

2/14/13

Topic Transcript

Option 4: This option is incorrect. Because users need to access, insert, delete, and modify data in
the datab ase, the DBA cannot deny privileges. If the DBA denies privileges, users cannot have the
privileges over the tab le.
Correct answer(s):
1. Create and assign user IDs to users
3. Grant privileges to users

Question
What is one of the limitations of using views?
Options:
1. Views created using complex queries may increase system overhead
2. Views provide security only for the columns available in them
3. You can only create a view with data from a single table
4. Users cannot update data because they can only retrieve data from views

Answer
Option 1: This option is correct. Complex queries may require more time and memory for
execution. When such queries are run to create a view, system overhead may increase.
Option 2: This option is incorrect. You do not create views to secure the columns availab le in them.
The columns in views can b e retrieved or modified b ased on users' privileges. Views are actually
created to restrict access to confidential data availab le in tab les.
Option 3: This option is incorrect. You can ob tain data from multiple tab les to create a view. Based
on their privileges over the respective columns in the tab les, users can retrieve or modify data
availab le in that view.
Option 4: This option is incorrect. Based on their privileges over a view, users can retrieve or modify
data. However, this depends on the permissions they have over the tab le that data is retrieved from
to create the view.
Correct answer(s):
1. Views created using complex queries may increase system overhead

2013 SkillSoft Ireland Limited

https://xlibrary.skillport.com/courseware/Content/cca/df_dbfn_a02_it_enus//output/t23/misc/transcript.html

10/10

S-ar putea să vă placă și