0% found this document useful (0 votes)
33 views27 pages

DBMS QB

The document discusses differences between NULL and 'NULL' in databases, how to create views, characteristics of updatable views, horizontal and vertical views, natural joins, domain integrity constraints, referential integrity constraints, entity integrity constraints, and examples of aggregate and scalar functions. NULL is a special marker for missing data while 'NULL' is a string. Views provide a virtual representation of query results. Updatable views allow modifying underlying data. Horizontal views organize across rows while vertical views organize along columns. Natural joins combine tables based on matching column names. Integrity constraints ensure data validity and relationships. Aggregate functions perform calculations on sets of values and scalar functions modify single values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views27 pages

DBMS QB

The document discusses differences between NULL and 'NULL' in databases, how to create views, characteristics of updatable views, horizontal and vertical views, natural joins, domain integrity constraints, referential integrity constraints, entity integrity constraints, and examples of aggregate and scalar functions. NULL is a special marker for missing data while 'NULL' is a string. Views provide a virtual representation of query results. Updatable views allow modifying underlying data. Horizontal views organize across rows while vertical views organize along columns. Natural joins combine tables based on matching column names. Integrity constraints ensure data validity and relationships. Aggregate functions perform calculations on sets of values and scalar functions modify single values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

UNIT 3

1.Explain Difference between NULL and ‘NULL’?


NULL: In the context of databases, NULL is a special marker used to indicate
that a data value does not exist in the database. It is not the same as an empty
string or zero; it's a unique value with its own significance. When a field in a
database table is set to NULL, it means that no valid data is present for that
field.
'NULL': On the other hand, 'NULL' is a string literal. It's a sequence of
characters that happens to spell out the word NULL. If you use single quotes
around NULL, it becomes a string containing the characters N, U, L, and L,
rather than the special marker indicating a lack of data.
For example:
SELECT * FROM table WHERE column_name IS NULL; checks for rows where
the column is actually NULL.
SELECT * FROM table WHERE column_name = 'NULL'; checks for rows where
the column has the string value 'NULL'.

2. What is view? Explain how to create a view.


A view in a Database Management System (DBMS) is a virtual table that is
based on the result of a SELECT query. It doesn't store the data itself but
provides a way to represent the result of a query as if it were a table. Views are
useful for simplifying complex queries, abstracting the underlying structure of
the database, and providing a level of security by restricting access to specific
columns or rows.
Here's a basic explanation of how to create a view:
Syntax:
CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
3. Write a short note on updatable view.
An updatable view in a database lets you change the data it shows, like adding,
updating, or deleting stuff. When you edit the view, it also edits the original
table, and vice versa. It's a handy tool for simplifying how you handle data,
giving users an easy way to make changes without dealing with all the nitty-
gritty details of the actual tables. But, not all views are updatable—there are
rules, like having a clear main table, no tricky calculations, and no fancy
groupings. Creating and handling these views needs some careful planning to
keep everything in check. Even though updatable views make editing data
easier, it's crucial to make sure your changes play nicely with the overall
database setup and keep things consistent.

4. Write a note on Horizontal View and Vertical view.


Horizontal View:
In a broader context, "horizontal" often refers to organizing or categorizing
data across rows. A horizontal view could imply looking at data across different
instances or entities. For example, if you have a table of employees, a
horizontal view might involve looking at the data for a specific employee across
various attributes or characteristics.
Vertical View:
Conversely, "vertical" usually implies looking at data along columns. A vertical
view might involve examining a specific attribute or characteristic across
different instances or entities. Using the employee table example, a vertical
view could mean looking at the salaries of all employees or a specific attribute
for the entire dataset.

5. What is Natural Join? Explain with example.


A natural join is a type of join operation in a relational database that combines
rows from two tables based on columns with the same name and data type.
The join condition is implicit and is determined by matching column names
between the tables. The result includes only the columns with unique names
from both tables.
Here's an example:
Consider two tables:
**Table 1: Employees**
| emp_id | emp_name | department_id | salary |
|--------|----------|---------------|--------|
|1 | Alice | 101 | 50000 |
|2 | Bob | 102 | 60000 |
|3 | Charlie | 101 | 55000 |
```
**Table 2: Departments**
```
| department_id | department_name |
|---------------|------------------|
| 101 | HR |
| 102 | IT |
| 103 | Finance |
```
Now, if you perform a natural join on the `department_id` column (which is
common between the two tables), the result would look like this:
```sql
SELECT * FROM Employees
NATURAL JOIN Departments;
```
**Result of Natural Join:**
```
| emp_id | emp_name | department_id | salary | department_name |
|
|1 | Alice | 101 | 50000 | HR |
|2 | Bob | 102 | 60000 | IT |
|3 | Charlie | 101 | 55000 | HR |
In this example, the natural join is performed on the `department_id` column,
which is common to both tables. The result includes columns from both tables,
but only the `department_id` is listed once in the output since it's the common
column. The `department_name` column is also included in the result because
it has the same name in both tables.

6. explain domain integrity constraints with example


Domain Integrity Constraints:
Domain integrity constraints ensure that the values in a database conform to a
specified set of permissible values or a specific domain. This constraint ensures
that the data entered into a column falls within a defined range or set of
values. It helps maintain the accuracy and validity of the data.
Example:
Let's say we have a table for storing information about employees, and we
want to ensure that the ages of employees are always 18 years or older. We
can use a domain integrity constraint with a CHECK constraint.
Code:
CREATE TABLE Employees (
employee_id INT PRIMARY KEY,
employee_name VARCHAR(50),
age INT CHECK (age >= 18)
);
In this example, the CHECK constraint ensures that the values entered into the
'age' column are greater than or equal to 18. If someone tries to insert a record
with an age less than 18, the database system will reject it, maintaining the
integrity of the domain (in this case, the valid range for age).
So, domain integrity constraints are about defining and enforcing rules for the
allowable values in a column, ensuring that data adheres to a specified
domain.

7. explain referential integrity constraints with example


Referential Integrity Constraints:
Referential integrity constraints ensure the consistency and accuracy of
relationships between tables. These constraints define rules that maintain the
relationships between foreign keys in one table and the primary keys in
another, preventing orphaned or inconsistent data.
Example:
Consider two tables, one for storing information about students and another
for storing information about the courses they are enrolled in.
Code:
CREATE TABLE Students (
student_id INT PRIMARY KEY,
student_name VARCHAR(50)
);
CREATE TABLE Courses (
course_id INT PRIMARY KEY,
course_name VARCHAR(50),
student_id INT,
FOREIGN KEY (student_id) REFERENCES Students(student_id)
);
In this example, the Courses table has a foreign key (student_id) that
references the primary key in the Students table. This establishes a
relationship where each course in the Courses table is associated with a
specific student in the Students table.
With this referential integrity constraint in place, the database system ensures
that every student_id in the Courses table must correspond to a valid
student_id in the Students table. If someone tries to insert a course with a
student_id that doesn't exist in the Students table, or if a student is deleted
from the Students table and has associated courses, the database system will
enforce referential integrity and prevent these actions.
Referential integrity constraints help maintain the integrity of relationships
between tables, preventing inconsistencies and ensuring that foreign key
references are always valid.

8. explain Entity Integrity Constraints with example


Entity Integrity Constraints:
Entity integrity constraints ensure the uniqueness and accuracy of the primary
key in a table. The primary key uniquely identifies each record in the table, and
entity integrity constraints maintain the consistency of this identification.
Example:
Let's consider a table to store information about books in a library. We want to
ensure that each book has a unique identifier, and this identifier is never null.
CREATE TABLE Books (
book_id INT PRIMARY KEY,
title VARCHAR(100),
author VARCHAR(50)
);
In this example, the book_id column is designated as the primary key. The
primary key constraint ensures that each book_id is unique for every row in
the Books table. Additionally, since it is the primary key, it implicitly enforces
entity integrity by disallowing null values in the book_id column.
Now, if someone tries to insert a record without providing a value for book_id
or attempts to insert a duplicate book_id, the database system will reject the
operation, maintaining the integrity of the primary key and ensuring that each
book in the library is uniquely identified.
Entity integrity constraints are fundamental for ensuring the consistency and
uniqueness of primary key values, preventing duplicate or null entries in the
primary key column.

9. Explain any 5 Aggregate Function with example.


COUNT():
Counts the number of rows in a set.
Example: Count the number of employees in a table.
SELECT COUNT(employee_id) FROM Employees;
SUM():
Calculates the sum of values in a numeric column.
Example: Calculate the total salary of all employees.
SELECT SUM(salary) FROM Employees;
AVG():
Computes the average of values in a numeric column.
Example: Find the average age of employees.
SELECT AVG(age) FROM Employees;
MIN():
Returns the minimum value in a set of values.
Example: Find the minimum salary among employees.
SELECT MIN(salary) FROM Employees;
MAX():
Returns the maximum value in a set of values.
Example: Find the maximum age of employees.
SELECT MAX(age) FROM Employees;
10. Explain any 5 Scalar Function with example.
UPPER():
Converts a string to uppercase.
Example: Convert the names of employees to uppercase.
SELECT UPPER(employee_name) FROM Employees;
LOWER():
Converts a string to lowercase.
Example: Convert the names of products to lowercase.
SELECT LOWER(product_name) FROM Products;
LENGTH() or LEN():
Returns the length (number of characters) of a string.
Example: Find the length of employee names.
SELECT LENGTH(employee_name) FROM Employees;
-- or
SELECT LEN(employee_name) FROM Employees;
ROUND():
Rounds a numeric value to a specified number of decimal places.
Example: Round the average salary to two decimal places.
SELECT ROUND(AVG(salary), 2) FROM Employees;
CONCAT():
Concatenates two or more strings.
Example: Combine the first name and last name of employees.
SELECT CONCAT(first_name, ' ', last_name) AS full_name FROM Employees;
11. Write a short note on DDL, DML, DCL & TCL
DDL (Data Definition Language):
DDL deals with the structure and definition of the database objects. It includes
commands for creating, altering, and deleting tables, indexes, views, and other
database structures.
Common DDL commands:
CREATE: Used to create new database objects like tables, indexes, etc.
ALTER: Modifies the structure of existing database objects.
DROP: Deletes existing database objects.
TRUNCATE: Removes all records from a table.
DML (Data Manipulation Language):
DML deals with the manipulation and processing of data within the database.
It includes commands for inserting, updating, retrieving, and deleting data.
Common DML commands:
SELECT: Retrieves data from one or more tables.
INSERT: Adds new records to a table.
UPDATE: Modifies existing records in a table.
DELETE: Removes records from a table.
DCL (Data Control Language):
DCL deals with the permissions and access control within the database. It
includes commands for granting or revoking privileges to users.
Common DCL commands:
GRANT: Provides specific privileges to a user.
REVOKE: Removes specific privileges from a user.
TCL (Transaction Control Language):
TCL deals with the management of transactions within the database. It
includes commands for defining the start and end of transactions and for
controlling the transactions' visibility and integrity.
Common TCL commands:
COMMIT: Saves changes made during the current transaction.
ROLLBACK: Undoes changes made during the current transaction.
SAVEPOINT: Sets a point within a transaction to which you can later roll back.
SET TRANSACTION: Modifies properties of the current transaction.

12. Write a Relational Set Operators in DBMS with example.


UNION:
The UNION operator is used to combine the result sets of two or more SELECT
statements without including duplicates.
Ex:
SELECT column1, column2 FROM table1
UNION
SELECT column1, column2 FROM table2;
This returns a combined result set, eliminating duplicate rows.
INTERSECT:
The INTERSECT operator is used to retrieve the common rows from two SELECT
statements.
Ex:
SELECT column1, column2 FROM table1
INTERSECT
SELECT column1, column2 FROM table2;
This returns only the rows that are common between the result sets of the two
SELECT statements.
EXCEPT (or MINUS):
The EXCEPT operator (or MINUS, depending on the database system) is used to
retrieve the rows that exist in the result set of the first SELECT statement but
not in the result set of the second SELECT statement.
Ex:
SELECT column1, column2 FROM table1
EXCEPT
SELECT column1, column2 FROM table2;
This returns the rows that are in the result set of the first SELECT statement
but not in the result set of the second SELECT statement.

13. Different types of Query in dbms


In a Database Management System (DBMS), there are various types of queries
that allow users to interact with the data. Here are some common types of
queries:
1. **Select Query: **
- Retrieves data from one or more tables. It is used to fetch information
based on specified criteria.
```sql
SELECT column1, column2 FROM table WHERE condition;
2. **Insert Query: **
- Adds new records to a table.
```sql
INSERT INTO table (column1, column2) VALUES (value1, value2);
3. **Update Query:**
- Modifies existing records in a table based on specified conditions.
```sql
UPDATE table SET column1 = value1 WHERE condition;
4. **Delete Query:**
- Removes records from a table based on specified conditions.
```sql
DELETE FROM table WHERE condition;
5. **Join Query:**
- Combines rows from two or more tables based on a related column
between them.
```sql
SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column;
6. **Aggregate Query:**
- Performs calculations on data, such as calculating the sum, average,
minimum, or maximum.
```sql
SELECT AVG(salary) FROM employees;
7. **Subquery:**
- Embeds one query inside another. A subquery can be used within SELECT,
FROM, WHERE, or HAVING clauses.
```sql
SELECT column1 FROM table WHERE column2 = (SELECT MAX(column2)
FROM table);
8. **Group By Query:**
- Groups rows that have the same values in specified columns, often used
with aggregate functions.
```sql
SELECT department, AVG(salary) FROM employees GROUP BY department;
9. **Order By Query:**
- Sorts the result set based on one or more columns.
```sql
SELECT * FROM table ORDER BY column1 ASC, column2 DESC;
These query types provide a powerful and flexible way to interact with
databases, allowing users to retrieve, manipulate, and manage data effectively.
14. Difference between Primary Key Constraint and Foreign Key
Difference Between Left, Right and Full Outer Join
Difference Between JOIN and UNION in SQL
**Primary Key Constraint vs. Foreign Key:**
- **Primary Key Constraint:**
- **Purpose:** Enforces uniqueness of values in a column or a set of columns,
and ensures that no NULL values are allowed in the specified column(s).
- **Usage:** Typically applied to the column(s) that uniquely identify each
row in a table.
- **Example:**
CREATE TABLE Students (
student_id INT PRIMARY KEY,
student_name VARCHAR(50)
);
- **Foreign Key:**
- **Purpose:** Establishes a link between data in two tables by referencing
the primary key of one table in another table. Enforces referential integrity.
- **Usage:** Applied to the column(s) in a table that references the primary
key of another table.
- **Example:**
CREATE TABLE Grades (
grade_id INT PRIMARY KEY,
student_id INT,
FOREIGN KEY (student_id) REFERENCES Students(student_id)
);
**Left, Right, and Full Outer Join:**
- **Left Outer Join:**
- Retrieves all records from the left table (the table mentioned before the
LEFT JOIN keyword) and matching records from the right table. If there's no
match, NULL values are returned for columns from the right table.
- **Syntax:**
SELECT * FROM table1 LEFT JOIN table2 ON table1.column = table2.column;
- **Right Outer Join:**
- Retrieves all records from the right table (the table mentioned before the
RIGHT JOIN keyword) and matching records from the left table. If there's no
match, NULL values are returned for columns from the left table.
- **Syntax:**
SELECT * FROM table1 RIGHT JOIN table2 ON table1.column =
table2.column;
- **Full Outer Join:**
- Retrieves all records when there is a match in either the left or right table. If
there's no match, NULL values are returned for columns from the non-
matching table.
- **Syntax:**
SELECT * FROM table1 FULL OUTER JOIN table2 ON table1.column =
table2.column;
**JOIN vs. UNION in SQL:**
- **JOIN:**
- **Purpose:** Combines rows from two or more tables based on a related
column between them.
- **Usage:** Used to retrieve columns from tables by matching values in
specified columns.
- **Example:**
SELECT * FROM table1 INNER JOIN table2 ON table1.column =
table2.column;
- **UNION:**
- **Purpose:** Combines the result sets of two or more SELECT statements
into a single result set. It removes duplicate rows.
- **Usage:** Used to combine rows from two SELECT statements with similar
structures.
- **Example:**
SELECT column1, column2 FROM table1
UNION
SELECT column1, column2 FROM table2;
In summary, primary key constraints and foreign keys are used for maintaining
data integrity, while different types of joins and unions in SQL serve different
purposes in combining and retrieving data from tables.
UNIT 4
1. Write the ACID properties. Explain the usefulness of each.
Atomicity: Guarantees that transactions are treated as indivisible units,
preventing partial changes. If a transaction fails, it's rolled back, maintaining
data integrity.
Consistency: Ensures that transactions bring the database from one valid state
to another, adhering to integrity constraints. Violating constraints results in a
rollback, preventing inconsistencies.
Isolation: When a transaction runs in isolation, it appears to be the only action
that the system is carrying out at one time.
Durability: A transaction is durable in that once it has been successfully
completed; all of the changes it made to the system are permanent.

2. Explain serializability. What is view serializability.


Serializability is a concept in database management systems that ensures that
the execution of transactions produces results equivalent to some serial
execution of those transactions. In other words, it guarantees a consistent and
valid state of the database despite the concurrent execution of multiple
transactions. Transactions are considered serializable if their interleaved
execution produces the same outcome as if they had been executed in some
sequential order.
View Serializability: Focuses on the final result sets or states produced by
transactions, rather than the specific operations within transactions. Two
schedules are view equivalent if they produce the same result when executed
on any consistent database state.

3. Write a note on conflict serializability


Conflict serializability is a key concept in database management systems,
ensuring the consistent and valid execution of transactions in a multi-user
environment. It focuses on identifying and managing conflicts between
transactions that share common resources. A conflict arises when at least one
of the transactions involves a write operation, leading to potential interference
with others. To achieve conflict serializability, the order in which conflicting
operations occur must be controlled. This control is established through
techniques such as locking or timestamping. The goal is to ensure that the final
state of the database, after the concurrent execution of transactions, is
equivalent to the result that would be obtained if the transactions were
executed in some sequential order. Conflict serializability plays a crucial role in
maintaining the integrity and consistency of databases, particularly in
scenarios where multiple transactions may concurrently access and modify
shared resources.

4. Explain the Two-Phase locking protocol


The Two-Phase Locking (2PL) protocol is a widely employed concurrency
control mechanism in databases. It operates in two phases: the growing phase,
where transactions acquire locks, and the shrinking phase, where locks are
released. Transactions follow a rule of acquiring all needed locks before
releasing any and refraining from acquiring new locks after releasing any. This
prevents conflicts and, notably, the occurrence of deadlocks. While effective,
the 2PL protocol can lead to conservative locking practices, impacting
concurrency. Nonetheless, its simplicity and effectiveness make it a widely
used method for ensuring consistency and isolation in database systems.

5. What is deadlock? Explain deadlock prevention


A deadlock in a database happens when transactions are blocked in a cyclic
waiting state. Deadlock prevention aims to break this circular waiting
condition. One strategy is the Two-Phase Locking (2PL) protocol, where
transactions acquire all required locks before releasing any and avoid acquiring
new locks after releasing any. Timeout mechanisms and deadlock detection
algorithms are also used. Timeouts release locks if transactions take too long,
and detection algorithms periodically check for circular waits. Employing these
prevention techniques minimizes deadlock occurrences, ensuring the smooth
functioning of a responsive database system.
6. Explain the timestamp ordering protocol.
The Timestamp Ordering protocol in databases uses timestamps to order
transactions. Each transaction is assigned a unique timestamp based on its
start time. This protocol ensures a serializable schedule by allowing a
transaction to read or write a data item only if its timestamp aligns with the
last transaction that wrote the item. It enables concurrent execution of
transactions with non-conflicting operations, enhancing efficiency in high-
concurrency scenarios. However, precise timestamp management is vital to
prevent anomalies and maintain database integrity.

7. What do you mean by concurrency execution? Write advantages of the


same.
Concurrency execution in the context of databases refers to the simultaneous
execution of multiple transactions or operations within the system. Instead of
waiting for one operation to complete before starting another, the system
allows overlapping or interleaved execution of tasks. This approach is essential
for optimizing system performance and responsiveness. Here are some
advantages of concurrency execution:
Increased Throughput:
Allows multiple transactions to proceed concurrently, enhancing overall
processing speed.
Improved Responsiveness:
Enhances user experience by providing quicker responses to queries.
Resource Utilization:
Optimizes system resources by preventing idle time, ensuring efficient usage.
Reduced Waiting Time:
Minimizes waiting time for transactions, leading to more efficient operations.
Optimized System Performance:
Handles a larger number of transactions concurrently, optimizing overall
performance.
Enhanced Scalability:
Accommodates growing user loads and transaction volumes without a
significant drop in performance.
Better Utilization of Multi-Core Processors:
Utilizes the processing power of multi-core processors effectively.

8. Explain wait–die and wound–wait techniques in deadlock Prevention.


In deadlock prevention, the wait–die and wound–wait techniques handle
conflicts between transactions to avoid circular waits and potential deadlocks.
1. Wait–Die Technique:
Categorizes transactions as "young" or "old" based on timestamps.
A young transaction can wait for a resource held by an old one, but if an old
transaction requests a resource held by a young one, the young one is aborted
and restarted.
2. Wound–Wait Technique:
Categorizes transactions as "victim" or "aggressor" based on timestamps.
If an aggressor transaction requests a resource held by a victim transaction,
the victim is aborted and restarted. However, if a victim requests a resource
held by an aggressor, it can wait.
Both techniques strategically abort transactions to break potential circular
waits, with the choice depending on transaction characteristics and priorities.
They are part of deadlock prevention strategies in managing conflicting
resource requests for consistent and deadlock-free database transactions.

9. How to recover system from deadlock.


Recovering from a deadlock involves detecting the situation and taking
corrective actions. Using a deadlock detection algorithm, the system can
identify deadlocks and decide on recovery strategies. One common approach is
to abort one or more transactions, releasing their resources. The choice of
which transactions to abort can consider factors like priority or age. Another
strategy is to temporarily suspend transactions, pre-emptively releasing
resources to break the deadlock, and then restarting the suspended
transactions. Recovery requires careful consideration to minimize impact on
performance and data integrity. Implementing prevention mechanisms can
also reduce the frequency of deadlocks and the need for recovery actions,
ensuring a more resilient database management system.

10. Explain the purpose of the checkpoint mechanism. How often should
checkpoints be performed?
The checkpoint mechanism in a database is vital for ensuring data consistency
and efficient recovery after a system failure. It involves periodically writing
modified data from volatile memory to non-volatile storage. Checkpoints
minimize recovery time by reducing the amount of data that needs restoration
and maintain data consistency by durably storing committed transactions.
Additionally, they optimize system performance by preventing the transaction
log from growing excessively. The frequency of checkpoints depends on factors
like recovery requirements, transaction volume, and system performance
goals. Striking a balance between data consistency, recovery time, and system
performance, checkpoints are typically performed at regular intervals based on
time or transaction activity.

11. Explain ARIES recovery method.


The ARIES (Algorithm for Recovery and Isolation Exploiting Semantics) recovery
method is a prominent technique in database systems for robust recovery
from failures. It combines write-ahead logging with a three-phase recovery
protocol: Analysis, Redo, and Undo. During Analysis, the system examines the
log to identify the recovery point. The Redo phase reverts the database to a
consistent state by reapplying logged changes. In the Undo phase, any
uncommitted transactions after the recovery point are rolled back. ARIES
efficiently recovers from system crashes and media failures, ensuring durability
and data consistency. Its structured logging and recovery protocol make it a
foundational approach in database systems for reliable transaction processing.
12. What is Schedules? Explain serial schedule and interleaved schedule with
help of scenario.
In database transactions, a schedule dictates the order of transaction
executions. A serial schedule involves executing transactions sequentially, one
after the other, ensuring no overlap in operations. This simplicity aids in
database management but might slow processing times. Conversely, an
interleaved schedule allows concurrent execution of transactions, enabling
their operations to overlap and improving throughput. For instance, in a fund
transfer scenario, a serial schedule would complete the transfer before
updating the balance, while an interleaved schedule might execute these
operations concurrently. Balancing the advantages of concurrency in
interleaved schedules with the challenges of consistency requires effective
concurrency control mechanisms like locks and isolation levels. The choice
between serial and interleaved schedules depends on the specific needs of the
database system.

13. Write a database recovery management algorithm.


In database recovery management, the ARIES (Algorithm for Recovery and
Isolation Exploiting Semantics) algorithm is a widely used approach. It employs
a three-phase protocol—Analysis, Redo, and Undo—along with write-ahead
logging. During the Analysis phase, the system examines the transaction log to
identify the recovery point. In the Redo phase, logged changes are reapplied to
bring the database to a consistent state up to the recovery point. The Undo
phase rolls back any uncommitted transactions after the recovery point. ARIES
efficiently handles various failures, ensuring the durability and consistency of
the database by employing a structured logging mechanism and a well-defined
recovery protocol.
14.

1. Active State – When the instructions of the transaction are running then the transaction is in
active state. If all the ‘read and write’ operations are performed without any error then it goes to the
“partially committed state”; if any instruction fails, it goes to the “failed state”.

2. Partially Committed – After completion of all the read and write operation the changes are made
in main memory or local buffer. If the changes are made permanent on the DataBase then the state
will change to “committed state” and in case of failure it will go to the “failed state”.

3. Failed State – When any instruction of the transaction fails, it goes to the “failed state” or if failure
occurs in making a permanent change of data on Data Base.

4. Aborted State – After having any type of failure the transaction goes from “failed state” to
“aborted state” and since in previous states, the changes are only made to local buffer or main
memory and hence these changes are deleted or rolled-back.

5. Committed State – It is the state when the changes are made permanent on the Data Base and the
transaction is complete and therefore terminated in the “terminated state”.

6. Terminated State – If there isn’t any roll-back or the transaction comes from the “committed
state”, then the system is consistent and ready for new transaction and the old transaction is
terminated.
UNIT 1
1. Draw a neat and labelled diagram of DBMS structure

2. What is mapping cardinality? Explain with suitable example. Mapping cardinality/cardinality ratio :
Mapping cardinality is the maximum number of relationship instances in which an entity can
participate.

1. One to one relationship(1:1) : It is represented using an arrow(⇢,⇠)(There can be many notations


possible for the ER diagram).
2.One to many relationship (1:M) :

This relationship is one to many because “There are some employees who manage more than one
team while there is only one manager to manage a team”.

3. Many to one relationship (M:1) :

4. Many to many relationship (M:N) :

3. What are the basic building blocks of data model? Explain with example.

A data model is a structure of the data that contains all the required details of the data like the name
of the data, size of the data, relationship with other data and constraints that are applied on the
data. It is a communication tool.

A data model constitutes of building blocks. They are:

1. Entities

2. Attributes
3. Relationships

4. Constraints

Entities:- Entities are real time objects that exist.It can be a person, place, object, event, concept.
Entities are represented by a rectangle box containing the entity name in it.

Example: Student, employee.

Attributes: It is the set of characteristics representing an entity.It is represented by a ellipse symbol


with attribute name on it.

Example: A student has attributes like name, roll number, age and much more.

Relationship: It describes the association between two entities.It is represented using diamond
symbol containing relationship name with it.The data model generally uses three kinds of
relationships:one to many, many to many, one to one.

Example: The relationship between two entities Student and Class has many to many relationship.

Constraints: Constraints are conditions applied on the data.It provides the data integrity.

Example: A student can take a maximum of 2 books from the library is applied as a constraint on the
student database.

4. explain the four basic business rules in DBMS


Business rules in a Database Management System (DBMS) define the structure
and behavior of data within an organization. Here are four basic business rules
commonly applied in DBMS:
Entity Integrity:
Rule: Every table must have a primary key, and each column participating in
the primary key must be non-null.
Purpose: Ensures that each record in a table is uniquely identified, and no
primary key attribute can have a null value. This guarantees the uniqueness
and identity of each entity.

Referential Integrity:
Rule: Foreign keys in a table must match primary keys in another table, or be
null.
Purpose: Maintains consistency between related tables. Ensures that
relationships between tables are valid, preventing the creation of "orphaned"
records with no corresponding parent records.
Domain Integrity:
Rule: Data values must fall within defined domains.
Purpose: Defines and enforces the acceptable range of values for each
attribute. This prevents the insertion of invalid or inconsistent data, ensuring
that data adheres to predefined rules.
Business Constraints:
Rule: Enforces specific business rules or logic that are not covered by the above
integrity constraints.
Purpose: Captures and enforces additional business-specific rules that might
not be covered by entity integrity, referential integrity, or domain integrity.
This ensures that the data meets specific business requirements.
These business rules are crucial for maintaining data quality, consistency, and
integrity within a database. They help to prevent errors, ensure accurate data
representation, and provide a foundation for reliable and meaningful
information in support of organizational processes.

5. Explain the concept of generalization with the help of an example in dbms


In the context of Database Management Systems (DBMS), generalization is a
process of organizing and structuring data in a way that higher-level entities
can inherit attributes and relationships from lower-level entities. It involves
creating a more abstract or generalized entity from a set of more specialized
entities. This concept is commonly associated with the design of relational
databases.
Example of Generalization:
Consider a scenario where you are designing a database for an educational
institution that offers various courses. You might have different types of
courses, such as "Computer Science," "Mathematics," and "Physics." Each of
these courses has some common attributes, but also some unique attributes.
Instead of creating separate tables for each type of course, you can use
generalization to create a more abstract entity called "Course," and then
derive more specific entities like "Computer Science Course," "Mathematics
Course," and "Physics Course" from it.
6. Explain the concept of specialization with the help of an example in dbms
In Database Management Systems (DBMS), specialization is a concept where a
more specific entity is derived from a more general entity. It's the reverse
process of generalization. Specialization involves creating sub-entities that
inherit attributes and relationships from a higher-level, more generalized
entity. Let's explore this concept with an example.
Example of Specialization:
Consider a scenario where you are designing a database for an organization
that has employees. You may have a generalized entity called "Employee," and
this entity can be specialized into different types of employees, such as
"Manager" and "Developer." Each specialized entity inherits attributes from
the general entity but may have additional attributes specific to its role.

You might also like