Final Exam
Final Exam
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:
The below sample will explain if DBMS using 2 phases locking protocol will be solve:
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.
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.