Uploaded by harsh raj

Database management system (2)

advertisement
Database management system
Previous year solution 2020
2(a) What are the five main functions of a database
administrator?
Ans:- A database administrator (DBA) is a person who is accountable
for the environmental aspects of a database. Or A Database
administrator is an individual person or a group of persons with an
overview of one or more databases. So that he/she can control the
design and the use of these databases.
There are following five main functions of a database
administrator.
a) Recoverability:- Recoverability is a property of database systems that ensures
that, in the event of a failure or error, the system can recover the database to a
consistent state. Recoverability guarantees that all committed transactions are durable
and that their effects are permanently stored in the database, while the effects of
uncommitted transactions are undone to maintain data consistency.
b) Integrity :- Data integrity is the overall completeness, accuracy and consistency
of data over its entire lifecycle. When data has integrity, mechanisms have been put in
place to ensure that data-in-use, data-in-transit and data-at-rest cannot be changed by an
unauthorized person or program.
c)Security:- Defining and/or implementing access controls to the data .
d)Physical database design :- Physical database design is the process of
transforming a data model into the physical data structure of a particular database
management system (DBMS).
e)Development and testing support:-Helping programmers and engineers to
efficiently utilize the database.
2(b) What are four main differences between file-processing
system and a DBMS?
Ans:- There are following four main differences between file-processing
system and a DBMS.
Basis
File-Processing
System
The file system is a
way of arranging
the files in a storage
medium within a
Structure computer.
Redundant data can
be present in a file
Data
Redundancy system.
It doesn’t provide
backup and
Backup and recovery of data if
Recovery it is lost.
There is no efficient
Query
processing query processing in
the file system.
DBMS
DBMS is
software for
managing the
database.
In DBMS there
is no redundant
data.
It provides
backup and
recovery of data
even if it is lost.
Efficient query
processing is
there in DBMS.
3. Construct an E-R diagram for a university registrar’s office.
The office maintains data about each class, including the
instructor, the enrollment, and the time and place of the class
meetings. For each class pair, a grade is recorded. Document
assumptions that you make about the mapping constraints.
Ans:- E-R diagram for according to question is as follows.
Room No.
Registrar’s Name
ID
Mobile No. of Registrar
Registrar Office
1
1
Has
Control
Instrctor_Id
M
M
Instructor’s Name
Instructor
Class
M
Time
M
1
Code
instruction
Subject
ClassId
Have
Subject
Enrollment_No.
M
M
Enrolled
Enrollment
Marks
Branch
Name
According to E-R Diagram, There are following Entities.
1.Registrar Office
2.Insturctor
3.Class
4.Enrollment
Registrar office have following attributes.
1. ID(Primary Key)
2. Room No.
3. Registrar’s Name
Instructor have following attributes.
1.
2.
3.
4.
Instructor’s_ID(Primary Key)
Instructor’s_Name
Code
Subject
Class have following attributes.
1. Class_ID(Primary Key)
2. Time
3. Subject
Enrollment have following attributes.
1.
2.
3.
4.
Enrollment_No.(Primary Key)
Marks
Branch
Name
According to E-R Diagram , Registrar Office have
two Relationship between Instructor and Class.
1. Relationship between Registrar Office and Instructor is one to many
relationship.
2. Relationship between Registrar Office and Class is one to many relationship
.
According to E-R Diagram , Instructor have two
Relationship between Enrollment and Class.
1.Relationship between Instructor and Enrollment is one to many relationship.
2. Relationship between Instructor and Class is Many to Many relationship.
According to E-R Diagram , Class have one
Relationship between Enrollment .
1.Relationship between Class and Enrollment is Many to many relationship.
4(a) What is the use of relational query language in DBMS? Use
the example to explain tuple and domain relational Calculus.
Ans:- There are some following uses of Relational Query Languages n DBMS.
1.Data Retrieval:- Relational Query Language provides a standardized and
structured way to retrieve data from the relational database.
2.Data Manipulation: RQL supports data manipulation operations, including
insertion, modification, and deletion of data in the database. Users can write
RQL statements to insert new records into tables, update existing records, or
delete records based on specific criteria.
3.Data Definition: Relational Query Language includes commands to define
the structure and schema of the database.
4.Data Integrity: Relational Query Language provides mechanisms to enforce
data integrity in the relational database.
5. Security and Access Control: Relational Query Language supports
access control mechanisms, allowing users to define permissions and
restrictions on who can perform specific operations on the database.
Tuples:- In the context of databases and the relational model, a tuple refers
to a single row or record in a table. It represents a collection of related data
items or attributes that describe a specific entity or instance. Each attribute in a
tuple corresponds to a specific column or field in the table.
Example:- Let's take an example of a simple table called "Students" to illustrate
tuples:Student_Id
Name
Age
Mobile No.
1
Deepak Kumar
21
62043567880
2
Vandna Kumari
20
9807896567
3
Atul Kumar
52
6201354552
In this example, each row represents a tuple in the "Students" table. Each
tuple contains four attributes: "StudentID," "Name," "Age," and "Mobile
No."
Domain:- In the context of databases, a domain refers to the set of all
possible values that an attribute or column in a table can hold. It defines the data
type and range of values that a particular attribute can take. Each attribute in a
table is associated with a specific domain.
Example:- Let's take an example of a simple table called "Students" to illustrate
domain:Student_Id
Name
Age
Mobile No.
1
Deepak Kumar
21
62043567880
2
Vandna Kumari
20
9807896567
3
Atul Kumar
52
6201354552
In this example, each column represents a domain in the "Students" table.
Each domain contains some data.
4(b) Explain the following operations with the help of examples :
(i)
Generalized Projection
(ii)
Outer Join
(iii)
Aggregate function
Ans:- i) Generalized projection :- Generalized projection, also known as
projection operation or projection query, is a fundamental operation in relational
algebra that retrieves specific columns or attributes from a table while discarding
the remaining columns. It allows you to create a new relation or table that includes
only the desired attributes.
The generalized projection operation is denoted using the π (pi) symbol. The
general syntax is:
π<attribute list>(relation)
Here's an example to illustrate the concept of generalized projection:
Consider a table called "Employees" with the following attributes:
EmployeeID
Name
Department
Salary
001
John
IT
5000
002
Mary
HR
6000
EmployeeID
Name
Department
Salary
003
David
IT
5500
004
Jessica
Sales
4500
If we want to retrieve only the "Name" and "Department" attributes from the
"Employees" table, we can apply generalized projection as follows:
π(Name, Department)(Employees)
The result of the generalized projection operation would be a new table with only
the selected attributes:
Name
Department
John
IT
Mary
HR
David
IT
Name
Department
Jessica
Sales
In this example, the generalized projection operation allows us to create a new
relation that contains only the "Name" and "Department" attributes from the
original "Employees" table. The remaining attributes, such as "EmployeeID" and
"Salary," are discarded in the result.
4(b)(ii)Ans:- Outer Join:- An outer join is a type of join operation in a
relational database that combines rows from two tables based on a related
column, including unmatched rows from one or both tables. It retrieves all the
matching rows from both tables, as well as any unmatched rows from one or
both tables.
Example of Outer Join:- Consider two tables, "Customers" and "Orders," with
the following data:
Customers Table:
CustomerID
CustomerName
1
John
CustomerID
CustomerName
2
Mary
3
David
Order Table are as follows
OrderID
CustomerID
OrderDate
101
1
2022-01-01
102
1
2022-02-01
SELECT Customers.CustomerID, Customers.CustomerName, Orders.OrderID,
Orders.OrderDate FROM Customers LEFT OUTER JOIN Orders ON
Customers.CustomerID = Orders.CustomerID;
Result:
CustomerID
CustomerName
OrderID
OrderDate
1
John
101
2022-01-01
1
John
102
2022-02-01
2
Mary
103
2022-03-01
3
David
null
null
4(b)(iii)Ans:- Aggregate Function:- An aggregate function in a
database is a function that operates on a set of values from a column or
expression and returns a single value summarizing the data. Aggregate
functions are commonly used in SQL queries to perform calculations on
groups of rows or on the entire table.
Here are some commonly used aggregate functions along with examples:
1. COUNT(): The COUNT() function returns the number of rows or nonnull values in a column or expression.
Example: SELECT COUNT(*) FROM Customers; This query returns the total
number of rows in the "Customers" table.
2. SUM(): The SUM() function calculates the sum of values in a column
or expression.
Example: SELECT SUM(Price) FROM Orders; This query returns the sum of all
"Price" values in the "Orders" table.
3. AVG(): The AVG() function calculates the average (mean) value of a
column or expression.
Example: SELECT AVG(Age) FROM Students; This query returns the average
age of all students in the "Students" table.
4. MIN(): The MIN() function retrieves the minimum value from a
column or expression.
Example: SELECT MIN(Salary) FROM Employees; This query returns the
lowest salary value from the "Employees" table.
5. MAX(): The MAX() function retrieves the maximum value from a
column or expression.
Example: SELECT MAX(Revenue) FROM Sales; This query returns the highest
revenue value from the "Sales" table.
5.Construct the B+ tree for the following set of key values :
{2,3,5,7,11,17,19,23,29,31}. Assume that tree is initially empty and
values are added in ascending order. Construct B+ tree for the
cases where the number of pointers that will fit in one node is as
follows:
(a) Four
(b) Six
(c) Eight
Ans(a) : Order of Four
5(b)Ans B+ Tree of Order of Six:-
5(c) Ans:- Order of Eight:-
6(a) List the ACID properties. Explain the usefulness of
each.
Answer:- The ACID properties are a set of fundamental properties that ensure
reliability, consistency, and integrity in database transactions. ACID stands for
Atomicity, Consistency, Isolation, and Durability. Let's explain the usefulness
of each property:
1. Atomicity: Atomicity guarantees that a transaction is treated as a single
indivisible unit of work. It ensures that either all the operations within a
transaction are completed successfully, or none of them are applied to the
database. If any part of the transaction fails, the entire transaction is rolled
back to its initial state, ensuring that the database remains consistent.
Usefulness: Atomicity helps maintain data integrity by ensuring that a
transaction's effects are all-or-nothing. It prevents situations where only a
portion of a transaction is applied, which could lead to inconsistent or incorrect
data.
2. Consistency: Consistency ensures that a transaction brings the database
from one valid state to another. It enforces a set of integrity constraints
defined on the database, such as data types, constraints, and relationships.
A transaction should not violate these constraints, ensuring that the data
remains valid and consistent throughout the transaction.
Usefulness: Consistency preserves data integrity by preventing transactions
from leaving the database in an inconsistent or invalid state. It guarantees that
only valid and consistent data is stored in the database, maintaining the integrity
of the application's data model.
3. Isolation: Isolation ensures that concurrent transactions are executed in a
way that they appear to be executed sequentially, one after the other.
Each transaction is isolated from other transactions until it is committed,
preventing interference or conflicts between concurrent transactions.
Isolation levels define the degree of isolation provided, such as Read
Uncommitted, Read Committed, Repeatable Read, and Serializable.
Usefulness: Isolation prevents concurrent transactions from interfering with
each other, avoiding issues like data inconsistencies, lost updates, and dirty
reads. It maintains the integrity and consistency of the data even in a multi-user
environment.
4. Durability: Durability guarantees that once a transaction is committed, its
changes are permanent and will survive any subsequent failures, such as
power outages, system crashes, or other forms of data loss. Committed
data is stored in a persistent storage medium (like disk) and can be
recovered even after a system failure.
Usefulness: Durability ensures data reliability by providing a mechanism for
recovering data in case of system failures. It allows users to have confidence
that once a transaction is committed, the changes will not be lost and can be
restored to the database.
6(b) What benefit is provided by rigorous two-phase locking?
How does it compare with other forms of two-phase locking?
Answer:- There are the following benefits provided by rigorous two-phase
locking:
1. Serializability: R2PL ensures serializability by preventing conflicts such
as dirty reads, non-repeatable reads, and lost updates between concurrent
transactions.
2. Consistency and Data Integrity: R2PL helps maintain data consistency
and integrity by ensuring that transactions operate on consistent states of
the database.
3. Deadlock Avoidance: R2PL helps in avoiding deadlocks by requiring
transactions to acquire all the required locks upfront during the growing
phase (Phase 1) of the protocol.
4. Predictability and Determinism: R2PL provides predictability and
determinism in transaction execution. As transactions strictly follow the
locking protocol, their execution order is well-defined and predictable.
Compared to other forms of two-phase locking, such as basic two-phase
locking (B2PL) or conservative two-phase locking (C2PL), R2PL
provides a stricter and more rigorous approach to concurrency control.
While B2PL and C2PL may allow some relaxation in acquiring or
releasing locks, R2PL enforces a stricter policy, ensuring stronger
guarantees of serializability and consistency.
Overall, the benefit of rigorous two-phase locking lies in its ability to provide
strict consistency, serializability, and predictable transaction execution, which
are essential in maintaining data integrity and correctness in a concurrent
database environment.
7(a) What is the purpose of having separate categories for
index authorization and resource authorization?
Answer:- The purpose of having separate categories for index authorization
and resource authorization is to provide fine-grained control and security in a
database system.
Index Authorization: Index authorization focuses on managing the access and
privileges related to database indexes. Indexes are data structures that improve
query performance by providing efficient access paths to data. With separate
index authorization, administrators can control who has permissions to create,
modify, or delete indexes, as well as perform operations such as rebuilding or
reorganizing indexes.
Benefits:



Control over Indexing: Separating index authorization allows
administrators to delegate index-related tasks to specific users or roles.
Performance Management: Index authorization enables fine-grained
control over index creation and modification, ensuring that only
authorized users can make changes that impact the query performance
and index structure.
Security and Confidentiality: By controlling index creation and
modification, sensitive or confidential data can be protected, limiting
access to authorized individuals or roles.
2.Resource Authorization: Resource authorization focuses on managing
access and permissions for the underlying database resources, such as
tables, views, stored procedures, or other objects
Benefits:


Data Security: Resource authorization ensures that only authorized users
or roles have access to specific data resources. It helps prevent
unauthorized data modifications or leaks by restricting access based on
user roles or privileges.
Data Integrity: By controlling resource authorization, administrators can
enforce data integrity rules, ensuring that only authorized users can

modify or delete data, thereby maintaining the accuracy and consistency
of the database.
Compliance and Auditing: Resource authorization provides a means to
enforce regulatory requirements by controlling access to sensitive data. It
allows administrators to monitor and track user actions, ensuring
compliance with data privacy and security regulations.
7(b) Explain the data mining and data warehousing related
to DBMS.
Ans:1. Data Mining: Data Mining refers to the process of discovering
patterns, relationships, and insights from large datasets. It involves
analyzing data using various statistical and machine learning
techniques to uncover hidden patterns and make predictions or
decisions based on the discovered knowledge.
Data mining techniques can be applied to structured and unstructured data
to extract valuable information. Some common data mining tasks include
classification, regression, clustering, association rule mining, and anomaly
detection. Data mining is useful for identifying trends, making predictions,
segmenting customers, detecting fraud, optimizing processes, and
supporting decision-making in various domains.
2. Data Warehousing: Data Warehousing involves the process of
collecting, organizing, and storing large volumes of data from various
sources to support business intelligence and decision-making. It is a
centralized repository that integrates data from multiple operational
systems, such as transactional databases, spreadsheets, and external
sources, into a unified and consistent format.
The primary goal of data warehousing is to provide a structured and
optimized environment for data analysis and reporting. Data is
transformed, cleaned, and loaded into the data warehouse using Extract,
Transform, Load (ETL) processes
Data warehouses support online analytical processing (OLAP) and reporting
tools, enabling users to perform complex queries, generate reports, and
gain insights from historical and aggregated data.
9.Write short notes on the following:
(a) RBAC model
(b) Concurrency Model
Ans: (a) RBAC model:- RBAC (Role-Based Access Control) can be
implemented in a database management system (DBMS) to provide a structured
and efficient approach to managing access control. The RBAC model in a
DBMS typically involves the following elements:
1. Roles: In the context of a DBMS, roles represent sets of privileges or
permissions that determine the actions users can perform on the database
objects. These privileges can include read, write, modify, execute, or any
other relevant operations on tables, views, stored procedures, or other
database objects.
2. Users: Users in a DBMS are individuals or entities who interact with the
database system. Each user is associated with one or more roles that
define their access rights and permissions within the database.
3. Permissions: Permissions in a DBMS specify the operations or actions
that users can perform on database objects. These permissions are
associated with roles and define the level of access granted to users
assigned to those roles.
4. Role Hierarchy: RBAC in a DBMS may support a role hierarchy, where
roles are organized in a hierarchical structure. Higher-level roles inherit
the permissions of lower-level roles.
5. Role Assignment: Role assignment in a DBMS involves associating users
with specific roles.
6. Access Control: RBAC in a DBMS enforces access control by evaluating
user access requests against their assigned roles and associated
permissions.
Ans: (b) Concurrency model:- Concurrency control in a database management
system (DBMS) is a crucial aspect that ensures multiple transactions can
execute concurrently without interfering with each other, while maintaining the
consistency and correctness of the database. Concurrency control models in
DBMS govern how transactions acquire, release, and coordinate access to
shared data to prevent conflicts and maintain data integrity. Here are some
commonly used concurrency control models:
1. Lock-Based Concurrency Control: Lock-based concurrency control is a
widely used mechanism in DBMS. It employs locks to control access to
shared resources, such as database tables or records, ensuring that only
one transaction can modify a resource at a time. Locks can be of various
types, including shared locks (read locks) and exclusive locks (write
locks).
 Shared Locks: Multiple transactions can acquire shared locks on a
resource simultaneously, allowing concurrent read access but preventing
write access by other transactions.
 Exclusive Locks: A transaction holding an exclusive lock has exclusive
access to a resource, preventing other transactions from both read and
write access.
2. Optimistic Concurrency Control: Optimistic concurrency control assumes
that conflicts between transactions are infrequent and allows transactions
to proceed without acquiring locks initially. However, before committing,
each transaction verifies that no other transaction has modified the data it
accessed during its execution.
 Validation: Transactions keep a record of the accessed data items and the
values before modification. During the validation phase, the DBMS
checks if any other transaction modified the same data items. If conflicts
are detected, appropriate actions such as transaction rollback or restarting
may be taken.
Optimistic concurrency control minimizes the overhead of lock acquisition and
release but requires careful handling of conflicts during the validation phase.
(Solved by vandna kumari(20cse43)
Download