Professional Documents
Culture Documents
Assignment No: 01
Assignment Title:
Submitted by:
Student ID: 182002037 Section: DB
Student Name: Safiqul Islam
Semester: Spring-20
Date of Submission: 07/06/2020
Submitted to:
MD ANSARUL ISLAM
Lecturer
Dept. of Computer Science and Engineering
Green University of Bangladesh
Answer:
❖ Atomicity:
the database considers all transaction operations as one whole unit or atom.
when a database processes a transaction, it is either fully completed or not
executed at all. If a single portion of the transaction fails, the whole transaction
will fail.
Example:
For example, user A wants to withdraw 50 tk from his account and then
transfer it to the account of user B. Each transaction (withdrawing 50 tk from
account A and transferring 50 tk to account B) is counted as separate. If the
first transaction (withdrawing 50 tk) fails because (say) the server crashes
during the transaction, user A cannot transfer the money to user B.
Atomicity is particularly important to mitigate damage in case of database
server crashes. If a non-volatile database crashes in the middle of a
transaction, all changes done will be discarded or rolled back to avoid sending
partial results to the production database.
❖ Consistency:
Consistency is key to maintain data integrity. All inconsistent data is discarded,
and all transactions that might cause an inconsistency are aborted. Consistency
is a property ensuring that only valid data following all rules and constraints is
written in the database. When a transaction results in invalid data, the
database reverts to its previous state.
Page 3 of 10
Example:
if user A wants to withdraw 1,000 tk from his account, but only has a balance
of 500 tk, consistency will prevent him from withdrawing money and the
transaction will be aborted.
❖ Isolation:
Isolation is a property that guarantees the individuality of each transaction,
and prevents them from being affected from other transactions. It ensures that
transactions are securely and independently processed at the same time
without interference, but it does not ensure the order of transactions.
Example:
User A withdraws 100 tk and user B withdraws 250 tk from user Z’s account,
which has a balance of 1,000 tk. Since both A and B draw from Z’s account,
one of the users is required to wait until the other user transaction is
completed, avoiding inconsistent Data.
If B is required to wait, then B must wait until A’s transaction is completed, and
Z’s account balance changes to 900 tk. Now, B can withdraw 250 tk from this
900 tk balance.
❖ Durability:
Durability is a property that enforces completed transactions, guaranteeing that
once each one of them has been committed, it will remain in the system even in
case of subsequent failures. If a transaction is successful, all changes generated
by it are stored permanently.
Example:
User B may withdraw 100 tk only after user A’s transaction is completed and is
updated in the database. If the system fails before A’s transaction is logged in
the database, A cannot withdraw any money, and Z’s account returns to its
previous consistent state.
Page 4 of 10
Answer:
➢ Conflict Serializability: If a given non-serial schedule can be converted
into a serial schedule by swapping its non-conflicting operations, then it
is called as a conflict serializable schedule.
Answer:
➢ SQL Query: select*from Facebook where first_name='Mehedi';
This given SQL Query can search the required data which is stored in first_name
attribute as Mehedi. But it will take long time to give the output. Because the
size of the database is huge.
For this query, these are 2 different ways that SQL could find the results:
1) Do a "full table scan": look at every single row in the table, return the
matching rows.
2) Create an "index": Make a copy of the table sorted by first_name, then
do a binary search to find the row where the first_name is "Mehedi",
find the matching IDs, then do a binary search on the original table that
returns the rows that match the ID.
It would be faster to do a binary search on a sorted table if we already had
that table created.
3) Also Hashing could be a very efficient way for this kind of problem. It
would be more faster then “Indexing”. Hashing technique is used to
calculate the direct location of a data record on the disk without using
index structure. In this technique, data is stored at the data blocks
whose address is generated by using the hashing function. The memory
location where these records are stored is known as data bucket or data
blocks. In this, a hash function can choose the first_name column value
to generate the address.
Page 6 of 10
Answer:
A functional dependency in databases is a dependency which satisfies
the properties of a function.
Symbol:
A→B
T1 T2
R(A)
W(A)
R(A)
R(B)
R(B)
W(B)
Answer:
➢ Conflict Serializability: If a given non-serial schedule can be converted
into a serial schedule by swapping its non-conflicting operations, then it
is called as a conflict serializable schedule.
To check Conflict serializability 1st we have to swap between R1(B) and R2(B)
and it’s possible they are not conflicting.
T1 T2
R(A)
W(A)
R(A)
R(B)
R(B)
W(B)
Then we swap between R1(B) and R2(A) and it’s possible they are not
conflicting.
T1 T2
R(A)
W(A)
R(B)
R(A)
R(B)
W(B)
Then we swap between W1(B) and R2(B) and it’s not possible because they are
conflicting.
So as the schedule is not serial schedule after swapping all non-conflicting
operations so we can say that this given schedule is not conflict Serializable.