DBMS 1
DBMS 1
DBMS 1
Questions
Q.No.
Explain the component modules of DBMS and their interaction, with help of a diagram
Solution :
➢ DDL compiler-processes schema definitions, specified in the DDL, and stores descriptions
of the schemas (meta-data) in the DBMS catalogue .
➢ Interactive query interface: interface for Casual users and persons with occasional need
for information from the database.
➢ Query compiler- validates for correctness of the query syntax, the names of files and data
elements & compiles them into an internal form.
Describe the characteristics of Database approach
Solution :
The main characteristics of the database approach versus the file-processing approach are the
following:
• Self-describing nature of a database system
• Insulation between programs and data, and data abstraction
2 • Support of multiple views of the data
• Sharing of data and multiuser transaction processing
➢ A multiuser DBMS, must allow multiple users to access the database at the same time.
Because the same database can be connected to multiple applications.
➢ The DBMS must include concurrency-control software to synchronize the access
requests of multiple users.
➢ These type of tasks are usually performed in applications such as bookmyshow, yono
SBI, IRCTC booking app, etc.
➢ These types of applications are generally called as online transaction
processing(OLTP) applications.
➢ A fundamental role of multiuser DBMS software is to ensure that concurrent transactions
operate correctly and efficiently.
Explain types of end-users with suitable examples
Solution :
End Users:
These are persons who access the database for querying, updating, and
report generation. There are several categories of end users :
• Casual end users: use database occasionally, needing different information each time; use
query language to specify their requests; typically middle- or high-level managers.
• Naive/Parametric end users: biggest group of users; frequently query/update the database
using standard canned transactions that have been carefully programmed and tested in
advance. Examples:
3
➢ bank tellers check account balances, post withdrawals/deposits
➢ reservation clerks for airlines, hotels, etc., check availability of seats/rooms and
make reservations.
• Sophisticated end users: includes engineers, scientists, business analysts, and others who
thoroughly familiarize themselves with the facilities of the DBMS in order to implement
their own applications to meet their complex requirements.
• Stand-alone users: maintain personal databases by using ready-made program packages that
provide easy-to-use menu-based or graphics-based interfaces.
➢ Ex: user of a tax package that stores a variety of personal financial data for tax
purposes.
Write the ER diagram for an employee database. The constraints are as follows:
i) An employee works for a department
ii) Every department is headed by a manager
iii) An employee works on one or more projects
4
iv) An employee has dependents
v) A department controls the projects
Solution :
List and explain the advantages of using DBMS
Solution :
1. Controlling Redundancy :
5 • Data redundancy such as tends to occur in the "file processing" approach leads to
wasted storage space, duplication of effort and a higher likelihood of the introduction
of inconsistency.
• In the database approach, the views of different user groups are integrated during
database design. This is known as data normalization, and it ensures consistency and
saves storage Space. However, it is sometimes necessary to use controlled
redundancy to improve the performance of queries.
4. Providing Storage Structures and Search Techniques for Efficient Query Processing :
• DBMS maintains indexes that are utilized to improve the execution time of queries
and updates.
• DBMS has a buffering or caching module that maintains parts of the database in
main memory buffers.
• The query processing and optimization module is responsible for choosing an
efficient query execution plan for each query submitted to the system.
The goal of the three-schema architecture is to separate the user applications from the physical
database. In this architecture, schemas can be defined at the following three levels:
1. The internal level has an internal schema, which describes the physical storage
structure of the database. The internal schema uses a physical data model and describes the
complete details of data storage and access paths for the database.
2. The conceptual level has a conceptual schema, which describes the structure of the whole
database for a community of users. The conceptual schema hides the details of physical
storage structures and concentrates on describing entities, data types, relationships, user
operations, and constraints. Usually, a representational data model is used to describe the
conceptual schema when a database system is implemented.
3. The external or view level includes a number of external schemas or user views. Each
external schema describes the part of the database that a particular user group is interested in
and hides the rest of the database from that user group. Each external schema is typically
implemented using a representational data model, possibly based on an external schema
design in a high-level data model.
➢ Hence, the DBMS must transform a request specified on an external schema into a
request against the conceptual schema, and then into a request on the internal schema for
processing over the stored database.
➢ The processes of transforming requests and results between levels are called mappings.
Explain the relational algebra operations from Set Thoery, with example.
Solution :
➢ UNION: The result of this operation, denoted by R ∪ S, is a relation that includes all tuples
that are either in R or in S or in both R and S. Duplicate tuples are eliminated.
7 ➢ INTERSECTION: The result of this operation, denoted by R ꓵ S, is a relation that includes
all tuples that are in both R and S.
➢ SET DIFFERENCE (or MINUS): The result of this operation, denoted by R - S, is a
relation that includes all tuples that are in R but not in S.
Note :
• Selection(σ): It is used to select required tuples of the relations.
• Projection(π): It is used to project required column data from a relation.
Example: Consider the the following two relations: STUDENT & INSTRUCTOR
Single relational algebra expression:
• UNION, INTERSECTION and SET DIFFERENCE are binary operations; that is, each is
applied to two sets (of tuples).
• When these operations are adapted to relational databases, the two relations on which any of
these three operations are applied must have the same type of tuples; this condition has been
called union compatibility or type compatibility.
➢ Both UNION and INTERSECTION obey associative law, they can be applicable to n-ary
operations :
Example :
➢ In SQL, CARTESIAN PRODUCT can be realized by using the CROSS JOIN option in
joined tables .
Given the schema :
Passenger(pid, pname, pgender, pcity)
Agency(aid, aname,acity)
Flight(fid,fdate,time,src,dest)
Booking(pid, aid,fid, fdate)
Identify and write relation algebra expression for the following:
i) Get the complete details of all flights to New Delhi
ii) Find only the flight numbers for passenger with pid 123 for flights to Chennai before
06/11/2020
8
Result = π_fid (σ_pid=123 and dest='Chennai' and fdate<'06/11/2020'(Booking ⨝
Flight))
iii) Find the passenger names for those who do not have any bookings in any flights
iv) Get the details of flights that are scheduled on both dates 01/12/2020 and 02/12/2020 at
16:00 hours
Result = π_fid, fdate, time, src, dest (σ_fdate='01/12/2020' and time='16:00' (Flight
⨝ ρ_fdate2,fid2,time2,src2,dest2(σ_fdate='02/12/2020' and time='16:00' (Flight))))
v) Find the details of all male passengers who are associated with jet agency
Identify and write SQL query for the following database schema:
Employee(employee_name, street, city)
Works(employee_name,company_name,salary)
Company(company_name, city)
Manages(employee_name, manager_name)
i) Find the names, street address, and cities of residence for all employees who work for 'First
Bank Corporation' and earn more than $10,000.
ii) Find the names of all employees in the database who do not work for 'First Bank Corporation'.
Assume that all people work for exactly one company.
SELECT employee_name
FROM Employee
WHERE employee_name NOT IN (SELECT employee_name FROM Works WHERE
company_name = 'First Bank Corporation');
iii) Find the names of all employees in the database who earn more than every employee of 'Small
10
Bank Corporation'. Assume that all people work for at most one company.
SELECT E.employee_name
FROM Employee E
JOIN Works W1 ON E.employee_name = W1.employee_name
WHERE W1.salary > ALL (SELECT W2.salary FROM Works W2 WHERE
W2.company_name = 'Small Bank Corporation');
iv) Find the name of the company that has the smallest payroll.
SELECT company_name
FROM Works
GROUP BY company_name
ORDER BY SUM(salary)
LIMIT 1;
v) Find the names of all employees in the database who live in the same cities and on the same
streets as do their managers.
SELECT E.employee_name
FROM Employee E
JOIN Manages M ON E.employee_name = M.employee_name
JOIN Employee Mgr ON M.manager_name = Mgr.employee_name AND E.city =
Mgr.city AND E.street = Mgr.street;
Explain the entity integrity and referential integrity constraints. Why is each considered important.
11
Give Examples.
12 Explain the ER to relational mapping algorithm with suitable example for each step