Answer 1
Answer 1
It can also be defined as the ability to execute many transactions in such a way that their combined
effect is same as they were executed in a sequentially manner. This practice ensures the data
consistency if there’s multiple transactions is running parallelly.
a. Conflict Serializability: This means if we can rearrange the execution order then we can say
it’s conflict serializability.
b. View Serializability: If the outcome of their execution is same following serial schedule then
it is consider as view serializability.
Recoverability means restoring the data if anything happens that can lead to data loss then it
ensures to restore the data. If a transaction commits only after all the transaction whose changes it
has read then it is called recoverable. This helps in preventing the rollbacks In difficult situations,
where failure of one transaction can lead to failure of others also.
Locking by it’s term is a mechanism that manages the access to database resources and helps in
maintaining the consistency during the rollbacks. Whenver locks present it prevents from conflicting
transaction to access same data again and again and makes the chance of error to less.
a. Shared Lock : Allows multiple transactions to read data resource but prevents writing.
b. Exclusive Locks: It allows single transaction to read or write a data resource.
Lock in nature helps in rollbacks by ensuring that no changes were done in resources and will not
cause any harm to transaction. Refer to the below steps to understand the locking mechanism:
a. Avoiding Cascading Rollback: This means when one transaction relies on another’s
uncommitted data then locking prevents from taking access to other’s uncommitted data
until the transaction have lock.
If the rollback happens the databases remain same or unaffected.
b. Preventing Dirty Reads: When a transaction acquires a shared or exclusive lock then it
ensures that no other transaction can read the uncommitted data resource.
-> If the rollback happens no transaction will participate thus preventing errors.
c. Two-phase Locking: It has two phases
-> Growing Phase: When a transaction aquires all the necessary locks.
-> Shrinking Phase: When a transaction releases the lock after transaction completed.
3. If the T1 rollbacks then changes to X are rejected and T2 will read the data.
2.
This means a model that presents the data in a graphical structure. In this model the data can be
presented as a records and the relationship among the records can be presented as pointers.
A schema is used to define the relation between the data and relationships. The records at a same
time can have multiple parents and child records. The conference on Data Systems language is a real
life example of the database security.
It is useful as it is supporting multiple parent and the child records, secondly as it uses pointers so
traversing is easy. It can also handles the complex queries.
1. Data is totally organized using graphs. 1. Data is organized using the trees like structure.
2. It uses pointers to locate between 2. It uses predefined way from the root to leaves.
Multiple records.
4. Queries is complex as it supports the 4. Queries here is simple but limited to the
many to many relation. Predefined structure of hierarchy.
The database management system involves the query to breakdown a high-level to low-level query
operation. This approach helps in manipulating and retrieval of data efficiently. It include selection,
projection, aggregation and set operation.
(A) Selection Operation: It retrieves the tuples that helps in satisfying specific conditions
example where clause.
a. Binary Search: This is applies when the data is sorted on the attribute called selection
attribute. It is efficient range queries and for equality. Cost is O(log n).
b. Index-based Search: It uses the indexes to pull out the tuples quickly. Cost associated is
O(log n) for B+ tree and O(1) for hash indexes.
c. Linear Search : It scans all the tuples sequentially and select only those which negotiate with
the condition. It is also used where no index exists. The cost is (O)n where n is number of the
tuples.
(B) Projection Operation: It helps in retrieving the specific columns from the relation.
* Naïve Method: It only scans the required columns and remove the duplicacy.
* Sort Based Projection: It sorts the tuples on the projected columns and identifies
duplicated and if there’s a duplicate present then it removes it.
* Hash Based Projection: It uses the hash based table to identify and remove duplicacy.
(C) Join Operation: It combines tuples from two relations by comparing the common attribute.
This is the most expensive solution in queries execution.
a. Nested loop join: In this the each tuple in outer relation, it basically scans the entire inner
relation to check and find the match. Cost is O(n*m).
b. Block Nested Loop Join: This processes only the blocks of the data thus preventing I/O. Cost in
this depends on the size of the blocks and the relations.
c. Sort Merge join: In this both the relations are sorted on the join attribute and then the merge
operation is performed. The cost is O(n log n +m log m ) for sorting.
d. Hash joins: In this one relation is distributed into buckets using the hash function mechanism
and other relation uses these buckets for matches. The cost is O(n+m).
(D) Sorting Operation: This is required for an operations that is order by and group by and joins.
Algorithms:
a. External merge sort: This is used for the data sets that is exceeding the memory or not fiiting
inside the memory. Cost is O(n log n).
b. In-Memory Sort: This is reverse of above algorithm, used for short datasets like Heapsort.
Cost is O(n log n).
4.
A) Database recovery means recovering the database to the existing or to back to normal state. This
is the technique to reconfigure or revive the database with the help of backups. The primary urge is
to maintain the intergrity and availability by undoing transaction.
Key components:
a. Loggings: This means taking logs of changes and any modification. This can also be explained
as a record keeping of any data modification and changes.
b. Snapshots: This means taking the pointer backup at a given point of time or taking backups.
c. Version Rollbacks: Helps in reverting the changes or in reverting the failed state.
a. Fast updates: This updates are applied so that it can be rollbacked easily.
b. Shadow paging: This is useful for recovery of the database to make sure the recovery
process without the logs.
B) Levels of Backup :
a. Full Backup: It is the backup of whole database that includes the metadata, logs and the data
Advantage:
b. Incremental backups: it takes the recent changes in the memory blocks and captures that
information only.
Advantage:
c. Differential Backups: It takes only the changes that is made since the last full or incremental
backups.
Advantage:
d. Mirror Backups: This means creating the exact same copy of the data in somewhere else.
Advantage:
5.
A) Physical query plan operators are used to do basic operations that is selection, projections,
joins and aggregation. The operators helps in retrieving the data efficiently from the ongoing
database.
a. Selection Operators: This is used to filter the rows on given condition. For example WHERE
b. Projection Operators: This is used to retrieve specific columns from the table.
d. Set Operators: It is used in operations like union, intersection and difference on tuples.
e. Aggregation Operators: It compute the functions like sum, avg, min, max.
Example:
Sort Based Aggregation: It makes job easier by sorting the tuples group attribute
before the aggregation process.
Hash based aggregation: Groups tuples using a hash based table.
This means the ample amount of data that is fitting our memory and making it efficient for
that memory size. It also helps in processing data in single pass.
Applications:
1. Selection: It reads each tuple and applies the selection predicate and write based on the
qualified tuple as the outputs.
Example: SELECT * FROM Students WHERE age > 16
2. Projection: It helps in extracting the data attributes while the scanning of dataset and
removal of the duplicates if required.
Example: SELECT DISTINCT department FROM Employees.
3. Aggregation: It reads the tuples and computes the aggregate functions then helps in storing
the result in the memory.
Example: SELECT AVG(salary) FROM Employee
Limitation: It is not suitable for the datasets that is large in size and another limitation is it requires
multipass algorithm for large scale operations.
6.
Aggregate functions are helpful for doing the calculation inside the SQL on set of defined values
and then returns the single value. Please find the list below:
Marks INT
);
Result:
Total_Students ar
Result:
Total_Marks
433
Result:
Average_Marks
86.6
Result:
Highest_Marks
92
Result:
Lowest_Marks
78
Result:
Students_Above_85
UPDATE student
’ ELSE 'C‘
’ND;
FROM student
GROUP BY Grade;
Result:
A 2 91
B 3 83.67