0% found this document useful (0 votes)
251 views8 pages

Final Exam

The document discusses database concepts including relations, indexes, transaction processing, and concurrency control. It defines a database relation as a table that stores the relationship between data in columns and rows. Indexes can improve query performance by allowing data to be sorted on specific columns. Transactions must follow the ACID properties - atomicity, consistency, isolation, and durability. Lock-based concurrency control protocols like two-phase locking can serialize transactions to avoid inconsistencies but cannot fully solve the phantom data problem. The document compares deferred and immediate modification approaches, where deferred only modifies data to the database after a transaction commits while immediate modification can happen before or after commit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
251 views8 pages

Final Exam

The document discusses database concepts including relations, indexes, transaction processing, and concurrency control. It defines a database relation as a table that stores the relationship between data in columns and rows. Indexes can improve query performance by allowing data to be sorted on specific columns. Transactions must follow the ACID properties - atomicity, consistency, isolation, and durability. Lock-based concurrency control protocols like two-phase locking can serialize transactions to avoid inconsistencies but cannot fully solve the phantom data problem. The document compares deferred and immediate modification approaches, where deferred only modifies data to the database after a transaction commits while immediate modification can happen before or after commit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Ahmad Khalid Oriakhil Final Exam 617-2381

Answers
1.
1.1. A relation is a subset of the Cartesian product of the domain. This means A
database relation simply refers to an individual table in a relational database. In a
relational database, the table is a relation because it stores the relation between data in
its column-row format. The columns are the table's attributes (primary key(s), candidate
key(s) and/or Foreign key(s), while the row(s) (tuple(s)) represent the data records or
the values for the attributes/keys.
1.2. Any sortable column can be used as an index (a pre-sorted row sequence). The
database engine can take advantage of existing indexes to find results to SQL queries
more quickly. If we see rows are frequently queried based on the birth-date, it's a good
idea to create an index for birth-date. Without the index, the database engine will
perform a sequential search. Once created, indexes are updated automatically. This has
a cost (space and update time). The primary key itself is an implicit index (or a set of
indexes) with unique values.
The primary index definition.
In the sequentially order file, the index whose search key specifies the sequential
order of the file.
− Also called clustering index
− The search key of a primary index is usually but not necessarily the primary
key.
1.3. A schedule is called Conflict Serializable: if it can be transformed into a serial
schedule by swapping non-conflicting operations.
Sample of conflict serializable
Schedule 3 is a conflict equivalent of schedule 6
Ahmad Khalid Oriakhil Final Exam 617-2381
Sample of not conflict serializable
- We are unable to swap sequence of operation.

1.4. Candidate key: concentrate on uniqueness and minimality (its actually is a super-
key which do not have another super key as subset). Candidate key must be unique
and minimum.
Index is an external access that point to the table. Key is the part of the data/table. And
meant to be a unique identifier (null is an identifier). Null is an attribute applicable
but values are unknown. Means in a table there’s a column with and attribute but the
values are null/not yet known.
Basically, a candidate key is a super-Key which competes to be a primary key.
1.5. Query optimization is the part of the query process in which the database system
compares different query strategies and chooses the one with the least expected cost.
The query optimizer, which carries out this function, is a key part of the relational
database and determines the most efficient way to access data.
Basically, we can say that the query optimization is the process optimizing the binary
search when data is ordered and physically clustered instead of using linear scan
technique which requires scan the entire table.
2.
2.1. transaction is logical unit of work in which integrity constraints are allowed to to be
evaluated. It comprises logical database statement. Inside of the transaction allow
integrity constraints to be temporarily evaluated.
A simple example of a transaction will be dealing with the bank accounts of two
users, let say Karlos and Ray. A simple transaction of moving an amount of 5000
from Karlos to Ray engages many low-level jobs. As the amount of Rs. 5000 gets
transferred from the Karlos's account to Ray's account, a series of tasks gets
performed in the background of the screen.
Ahmad Khalid Oriakhil Final Exam 617-2381
This straightforward and small transaction includes several steps: decrease Karlos's
bank account from 5000:
Open_Acc (Karlos)
OldBal = Karlos.bal
NewBal = OldBal - 5000
Ram.bal = NewBal
CloseAccount(Karlos)
2.2. The ACID properties are the property of the transaction that using one capital character
to describes each property.
a) Atomicity: Either all operations of the transaction are properly reflected in the database,
or none are. Atomicity must be ensured by DBMS.
b) Consistency: Execution of a transaction in isolation preserves the consistency of the
database.
c) Isolation (responsible by DBMS): Although multiple transactions may execute
concurrently, each transaction must be unaware of other concurrently executing
transactions. Intermediate transaction results must be hidden from other concurrently
executed transactions.
d) Durability: After a transaction completes successfully, the changes it has made to the
database persist, even if there are system failures. If the failure occurs after the commit
of transaction, the transaction result should persist and the DBMS must handle this.

The ACID has an important role in relational database as it guarantees database transactions
are processed reliable (when we talk about reliability, this includes all the possible
problems a relational database can have). ACID is especially concerned with how a
database recovers from any failure that might occur while processing a transaction

2.3. The most important aspect of a database is the ability to store data and the ability
to manipulate data. COMMIT and ROLLBACK are two such keywords which are
used in order store and revert the process of data storage. These keywords are usually
used in context with a transaction.
COMMIT is the SQL command that is used for storing changes performed by a
transaction. When a COMMIT command is issued it saves all the changes since last
COMMIT or ROLLBACK.
Ahmad Khalid Oriakhil Final Exam 617-2381
ROLLBACK is the SQL command that is used for reverting changes performed by
a transaction. When a ROLLBACK command is issued it reverts all the changes
since last COMMIT or ROLLBACK.
COMMIT and ROLLBACK are performed on transactions. A transaction is the
smallest unit of work that is performed against a database. Its a sequence of
instructions in a logical order. A transaction can be performed manually by a
programmer or it can be triggered using an automated program.
3.
3.1. Level of consistency will sort by best to worst

• Serializable – default
• Repeatable read - only committed records to be read, repeated reads of same
record must return same value. However, a transaction may not be serializable -
it may find some records inserted by a transaction but not find others.
• Read committed - only committed records can be read, but successive reads
of record may return different (but committed) values.
• Read uncommitted - even uncommitted records may be read.

3.2. Lock base protocol still can’t solve all of 4 concurrency control problem because
of Lock-compatibility matrix as following
• A transaction may be granted a lock on an item if the requested lock is compatible with
locks already held on the item by other transactions.
• Any number of transactions can hold shared locks on an item;
• But if any transaction holds an exclusive on the item no other transaction may hold
any lock on the item.
Ahmad Khalid Oriakhil Final Exam 617-2381
The Two-Phase Locking Protocol:

• This is a protocol which ensures conflict-serializable schedules.


• Phase 1: Growing Phase
- Transaction may obtain locks
- Transaction may not release locks
• Phase 2: Shrinking Phase
- Transaction may release locks
- Transaction may not obtain locks
• The protocol assures serializability. It can be proved that the transactions can be
serialized in the order of their lock points (i.e. the point where a transaction acquired
its final lock).
• Two-phase locking does not ensure freedom from deadlocks
• Cascading roll-back is possible under two-phase locking. To avoid this, follow a
modified protocol called strict two-phase locking. Here a transaction must hold all
its exclusive locks till it commits/aborts.
• Rigorous two-phase locking is even stricter: here all locks are held till commit/abort.
In this protocol transactions can be serialized in the order in which they commit.

The below sample will explain if DBMS using 2 phases locking protocol will be solve:

1. Lost update problem


2. Uncommitted dependency problem
3. Inconsistent analysis problem
By convert wrong scheduling into Dead Lock so wrong result won’t come out.

The below transaction can be lock 1 by 1 but theAcc4 still can be insert as another row in to
schedule so the locking techniques still can’t solve Phantom Phenomenon Problem.
Ahmad Khalid Oriakhil Final Exam 617-2381
Ahmad Khalid Oriakhil Final Exam 617-2381

4.
4.1.

Deferred Modification Immediate Modification


The transaction must commit first Both commit and not commit
before DB notification could take place. transaction could take place of DB
notification from buffer.

Database from the buffer modify to DB


space only after commit. Data base modification could take place
before or after commit.
Ahmad Khalid Oriakhil Final Exam 617-2381

4.2.
The backup concept that no need to back up everything every day and it process
backup only the modified portion but it still needs periodically volume backup by
explain as following figure has volume backup every SAT and the rest it processes
daily backup only modified portion.

You might also like