DBMS CAT 3 Assignments
DBMS CAT 3 Assignments
ASSIGNMENT OF UNIT 1
Subject Teacher:
Mrs Parvesh
QUESTION 1
DBMS is a collection of programs that enable users to create and maintain a database. The DBMS
is hence a General purpose software system that facilitates the processes of defining, constructing
Database management system (DBMS) consists of a collection of interrelated data and a set of
programs to access that data. The collection data is usually referred to as data base which contains
The primary goal of a DBMS is to provide an environment that is both convenient and efficient to
use in retrieving and storing data base information. The DBMS is the interface between the user of
application programs on one hand and the data base on the other.
The objective of a database management system is to facilitate the creation of data structures and
relieve the programmer of the problems of setting up complicated files. Data base management
systems have developed from a concept of the data base as something distinct from the programs
accessing it.
QUESTION 2
Used to manage and organise the files stored in A software to store and retrieve the user’s data
the hard disk of the computer
Less complex, does not support complicated More complexity in managing the data, easier to
transactions implement complicated transactions
Less security Supports more security mechanisms
Less expensive in comparison to DBMS Higher cost than the File system
Does not support crash recovery Crash recovery mechanism is highly supported
QUESTION 3
MySQL Database
MS- Access
MS- Access
Oracle Database
IBM DB2
Microsoft SQL Server
Amazon RDS
File Maker
NoSQL
Postgresq
MS Fox Pro
Ingres
Adabas
QUESTION 4
Three-tier architecture of DBMS.
Tier-3 Architecture
The 3-tier architecture contains one more layer between the client and the server.
In this architecture, there is no direct communication between client and server.
Mainly, the 3-tier is used for large applications on the web.
The features of 3-tier architecture are data backup, recovery, security, and
concurrency control.
Layers
The 3-tier architecture consists of the three layers as follows −
Presentation layer − This layer is also called the client layer. The front-end layer
consists of a user interface. The main purpose is to communicate with the application
layer.
Application layer − This layer is also called the business logic layer. It acts as a
middle layer between the client and the database server which are used to exchange
partially processed data.
Database layer − In this layer the data or information is stored. This layer performs
operations like insert, update and delete to connect with the database.
QUESTION 5.
QUESTION 6
In 1-tier architecture, the data is directly provided to the user and that user can directly use the
database through the computer.
Any changes or updates that are done will reflect directly to the database.
The 1-tier architecture is used for the development of applications where a
programmer directly communicates with the database for very fast response.
It is used for enhancement of the local application.
QUESTION 7
QUESTION 8
Explain DDL, DML, DCL and TCL.
o CREATE
o ALTER
o DROP
o TRUNCATE
o INSERT
o UPDATE
o DELETE
o Grant
o Revoke
TCL commands can only use with DML commands like INSERT, DELETE and UPDATE only.
These operations are automatically committed in the database that's why they cannot be used while
creating tables or dropping them.
o COMMIT
o ROLLBACK
o SAVEPOINT
o SELECT
B. Tech. CSE Second Year
Semester 3 Fall-2022-23
Subject: DBMS
ASSIGNMENT OF UNIT 2
Subject Teacher:
Mrs Parvesh
QUESTION 1
Write SQL query to get the Student name whose salary is between 1000 and 2000.
SELECT *
FROM employees
WHERE salary BETWEEN (SELECT 1000) AND 2000;
QUESTION 2
Write SQL query to get the Students Name and address from Student table .
QUESTION 3
Write SQL query to get the Students Name who have got marks greater than 90 from Student
table
select student_name
from student join mark using (student_id)
group by student_name
having min(value) > 90
order by student_name;
QUESTION 4
Union
Union combines two different results obtained by a query into a single result in the form of a table.
However, the results should be similar if union is to be applied on them. Union removes all
duplicates, if any from the data and only displays distinct values. If duplicate values are required in
the resultant data, then UNION ALL is used.
An example of union is −
QUESTION 5
In DBMS, a join statement is mainly used to combine two tables based on a specified
common field between them. If we talk in terms of Relational algebra, it is the cartesian product
of two tables followed by the selection operation. Thus, we can execute the product and selection
process on two tables using a single join statement. We can use either 'on' or 'using' clause in
MySQL to apply predicates to the join queries.
1. Inner Join
Inner Join is a join that can be used to return all the values that have matching
values in both the tables.
2. Outer Join
Outer Join is a join that can be used to return the records in both the tables whether
it has matching records in both the tables or not.
QUESTION 6
1 CSE A
2 ECE B
3 CIVIL A
4 IT B
Table R2
Name RegNo
Bhanu 2
Priya 4
R1 X R2
RegNo Branch Section Name RegNo
1 CSE A Bhanu 2
1 CSE A Priya 4
2 ECE B Bhanu 2
2 ECE B Priya 4
3 CIVIL A Bhanu 2
3 CIVIL A Priya 4
4 IT B Bhanu 2
RegNo Branch Section Name RegNo
4 IT B Priya 4
QUESTION 7
Select Operation : This operation is used to select rows from a table (relation) that specifies
a given logic, which is called as a predicate. The predicate is a user defined condition to
select rows of user's choice.
Project Operation : If the user is interested in selecting the values of a few attributes,
rather than selection all attributes of the Table (Relation), then one should go
for PROJECT Operation.
Select operations : Select operation displays the records for the condition. Select operation is
denoted by sigma (σ).
Syntax:
σcondition(TableName)
Example:
RollNo
012
013
015
ASSIGNMENT OF UNIT 3
Subject Teacher:
Mrs Parvesh
Question 1.
What is partial functional dependency?
A functional dependency A → B is said to be partial if removal of any subset of A still able to
recognize B uniquely.
Partial Dependency is a form of Functional dependency that holds on a set of attributes. It is about
the complete dependency of a right hand side attribute on one of the left hand side attributes.
For example, in a functional dependency PQ → R, if either P alone or Q alone can uniquely
identify R, then this is said to be Partial Functional Dependency. We read this as R is partially
functionally dependent on P or R is partially functionally dependent on Q.
Question 2.
What is transitive functional dependency?
X -> Z is a transitive dependency if the following three functional dependencies hold true:
X->Y
Y does not ->X
Y->Z
Note: A transitive dependency can only occur in a relation of three of more attributes. This
dependency helps us normalizing the database in 3NF (3rd Normal Form).
Question 3.
What is full functional dependency?
Full functional dependency is defined as all the non candidate key attributes fully depends upon
primary key attribute.
For Example,
Employee(id,name,location)
Where,
name and location -> non primary key attributes ; id -> primary key attribute.
to maintain consistency
to avoid insertion anomaly problem
QUESTION 4.
Explain 1NF, 2NF, 3NF, BCNF, 4NF with Example
EMPLOYEE table:
14 John 7272826385, UP
9064738238
The decomposition of the EMPLOYEE table into 1NF has been shown below:
14 John 7272826385 UP
14 John 9064738238 UP
TEACHER table
25 Chemistry 30
25 Biology 30
47 English 35
83 Math 38
83 Computer 38
To convert the given table into 2NF, we decompose it into two tables:
TEACHER_DETAIL table:
TEACHER_ID TEACHER_AGE
25 30
47 35
83 38
TEACHER_SUBJECT table:
TEACHER_ID SUBJECT
25 Chemistry
25 Biology
47 English
83 Math
83 Computer
Third Normal Form (3NF)
o A relation will be in 3NF if it is in 2NF and not contain any transitive partial dependency.
o 3NF is used to reduce the data duplication. It is also used to achieve the data integrity.
o If there is no transitive dependency for non-prime attributes, then the relation must be in
third normal form.
A relation is in third normal form if it holds atleast one of the following conditions for every non-
trivial function dependency X → Y.
1. X is a super key.
2. Y is a prime attribute, i.e., each element of Y is part of some candidate key.
Example:
EMPLOYEE_DETAIL table:
1. {EMP_ID}, {EMP_ID, EMP_NAME}, {EMP_ID, EMP_NAME, EMP_ZIP}....so on
Candidate key: {EMP_ID}
Non-prime attributes: In the given table, all attributes except EMP_ID are non-
prime.
Here, EMP_STATE & EMP_CITY dependent on EMP_ZIP and EMP_ZIP dependent on
EMP_ID. The non-prime attributes (EMP_STATE, EMP_CITY) transitively dependent
on super key(EMP_ID). It violates the rule of third normal form.
That's why we need to move the EMP_CITY and EMP_STATE to the new
<EMPLOYEE_ZIP> table, with EMP_ZIP as a Primary key.
EMPLOYEE table:
201010 UP Noida
02228 US Boston
60007 US Chicago
06389 UK Norwich
462007 MP Bhopal
EMPLOYEE_ZIP table:
Example: Let's assume there is a company where employees work in more than one department.
EMPLOYEE table:
1. EMP_ID → EMP_COUNTRY
2. EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
The table is not in BCNF because neither EMP_DEPT nor EMP_ID alone are keys.
To convert the given table into BCNF, we decompose it into three tables:
EMP_COUNTRY table:
EMP_ID EMP_COUNTRY
264 India
264 India
EMP_DEPT table:
EMP_DEPT_MAPPING table:
EMP_ID EMP_DEPT
D394 283
D394 300
D283 232
D283 549
Functional dependencies:
1. EMP_ID → EMP_COUNTRY
2. EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
Candidate keys:
QUESTION 5.
What is the difference between 3NF and BCNF.
S.NO. 3NF BCNF
It is comparatively more
2. It is less stronger than BCNF. stronger than 3NF.
The redundancy is
4. The redundancy is high in 3NF. comparatively low in BCNF.
Question 6.
R(C, S, Z)
CS→Z
Z→C
QUESTION 7.
ename, did->salary
empid->ename
QUESTION 8.
R(A,B,C,D,E)
A->BC
BC->E
E->DA
B. Tech. CSE Second Year
Semester 3 Fall-2022-23
Subject: DBMS
ASSIGNMENT OF UNIT 4
Subject Teacher:
Mrs Parvesh
QUESTION 1.
What is concurrent schedule?
A schedule is said to be concurrent in case the instructions of the transactions get executed
preemptively.
When the database system executes several transactions concurrently, the corresponding schedule
no longer needs to be serial.
If two transactions are running concurrently, the operating system may execute one transaction for
a little while, then perform a context switch, execute the second transaction for some time, and then
switch back to the first transaction for some time, and so on. With multiple transactions, the CPU
time is shared among all the transactions.
Several execution sequences are possible, since the various instructions from both
transactions may now be interleaved.
In general, it is not possible to predict exactly how many instructions of a transaction will be
executed before the CPU switches to another transaction.
Thus, the number of possible schedules for a set of n transactions is much larger than n!.
Concurrent schedules might get affected with conflicting operations and hence does not give
guaranty for data consistency.
QUESTION 2.
What is deadlock?
A deadlock is a situation in which two computer programs sharing the same resource are effectively
preventing each other from accessing the resource, resulting in both programs ceasing to function.
The earliest computer operating systems ran only one program at a time. All of the resources of the
system were available to this one program. Later, operating systems ran multiple programs at once,
interleaving them. Programs were required to specify in advance what resources they needed so that
they could avoid conflicts with other programs running at the same time. Eventually some
operating systems offered dynamic allocation of resources. Programs could request further
allocations of resources after they had begun running. This led to the problem of the deadlock. Here
is the simplest example:
Now neither program can proceed until the other program releases a resource. The operating system
cannot know what action to take. At this point the only alternative is to abort (stop) one of the
programs.
Learning to deal with deadlocks had a major impact on the development of operating systems and
the structure of databases. Data was structured and the order of requests was constrained in order to
avoid creating deadlocks.
QUESTION 3.
What do you mean by serializable schedule.
A non-serial schedule is called a serializable schedule if it can be converted to its equivalent serial
schedule. In simple words, if a non-serial schedule and a serial schedule result in the same then the
non-serial schedule is called a serializable schedule.
Transaction-1 Transaction-2
R(a)
W(a)
R(b)
W(b)
R(b)
R(a)
W(b)
W(a)
QUESTION 4.
1. Serial Schedule - A schedule in which only one transaction is executed at a time, i.e., one
transaction is executed completely before starting another transaction.
Example:
Transaction-1 Transaction-2
R(a)
W(a)
R(b)
Transaction-1 Transaction-2
W(b)
R(b)
W(b)
R(a)
W(a)
QUESTION 5.
A transaction in a database system must maintain Atomicity, Consistency, Isolation, and Durability
− commonly known as ACID property − in order to ensure accuracy, completeness, and data
integrity.
Atomicity
Consistency
Isolation
Durability
Atomicity: –
A transaction is an atomic unit of processing.
It is either performed entirely or not performed at all.
Means either all operations are reflected in the database or none are.
It is the responsibility of the transaction recovery subsystem to ensure atomicity.
moreover, If a transaction fails to complete for some reason, the recovery technique must
undo any effects of the transaction on the database.
Consistency: –
A transaction is consistency preserving if its complete execution takes the database from
one consistent state to another.
It is the responsibility of the programmer who writes database programs.
Database programs should be written in such a way that, if the database is in a consistent
state before execution of transaction. After That it will be in a consistent state after
execution of transaction.
For instance, Transaction is :- Transfer $50 from account A to account B.
If account A having amount $100 & account B having amount $ 200 initially then after
execution of transaction, A must have $ 50 & B must have $ 250.
Isolation: –
If multiple transactions execute concurrently. They should produce the result as if they are
working serially.
Further, It is enforce a concurrency control subsystem.
To avoid the problem of concurrent execution, transactions should be executed in isolation.
Durability: –
The changes applied to the database, by a committed transaction must persist in a database.
The changes may not be lost because of any failure.
It is the responsibility of the recovery subsystem of the DBMS.
QUESTION 6.
check the given schedule is serializable or not.
Consider the following schedule for transaction T1, T2, T3
T1 T2 T3
r(x)
r(y)
r(y)
w(y)
w(x)
w(x)
r(x)
w(x)
Testing of Serializability
Assume a schedule S. For S, we construct a graph known as precedence graph. This graph has a
pair G = (V, E), where V consists a set of vertices, and E consists a set of edges. The set of vertices
is used to contain all the transactions participating in the schedule. The set of edges is used to
contain all edges Ti ->Tj for which one of the three conditions holds:
Explanation:
A non-serial schedule is called a serializable schedule if it can be converted to its equivalent serial
schedule. In simple words, if a non-serial schedule and a serial schedule result in the same then the
non-serial schedule is called a serializable schedule
Hence the given schedule is serializable
ASSIGNMENT OF UNIT 5
Subject Teacher:
Mrs Parvesh
QUESTION 1
What is temporary update problem?
The Lost Update problem arises when an update in the data is done over another update but by
two different transactions.
Time A B
T1 READ(DT) ------
T2 DT=DT+500 ------
T3 WRITE(DT) ------
T4 ------ DT=DT+300
T5 ------ WRITE(DT)
T6 READ(DT) ------
Transaction A initially reads the value of DT as 1000. Transaction A modifies the value of DT from
1000 to 1500 and then again transaction B modifies the value to 1800. Transaction A again reads
DT and finds 1800 in DT and therefore the update done by transaction A has been lost.
The Temporary Update Problem. • Occurs when a transaction fails but updated item is accessed
by another transaction before it is changed back to its original value.
QUESTION 2
Explain Two Phase Locking Protocol
QUESTION 3
What is the objective to do concurrency control?
QUESTION 4
Explain Dirty read problem.
Dirty read is a read of uncommitted data. If a particular row is modified by another running
application and not yet committed, we also run an application to read the same row with the same
uncommitted data. This is the state we say it as a dirty read.
The one main thing is that the dirty reader has to stop reading dirty.
We can try to use the shared locks to prevent other transactions to modify the row, if one is carried
out here.
Example of dirty read problem
A dirty read occurs when a transaction reads data that has not yet been committed.
Example 1
Step 1 − Consider we have an online shopping system where users can buy and view
the buyer products at the same time.
Step 2 − Let us suppose a case in which a user tries to buy a product , and as soon as
the user buys the product then the count value in update stock will change
immediately.
Step 3 − Let us consider that there were 10 items in stock, but now they are 9.
Step 4 − Moreover due to this transaction, there will also be communication with the
billing gateway.
Step 5 − Meanwhile, if there is any other user who has also done a transaction at the
same time, the new user will be able to see 9 items in the stock.
Step 6 − But, let us suppose that the first user was unable to complete his/her
transactions due to some error or insufficient funds.
Step 7 − Then, in this case the transaction done by the first user will roll back and
now the value in stock will be 10 again.
Step 8 − But, when the 2nd user was doing a transaction the no items in stocks were
9.
Step 9 − This is called DIRTY DATA and this whole problem is called the Dirty
Problem.
QUESTION 5
What is concurrency control?
Concurrency control concept comes under the Transaction in database management system
(DBMS). It is a procedure in DBMS which helps us for the management of two simultaneous
processes to execute without conflicts between each other, these conflicts occur in multi user
systems.
Concurrency can simply be said to be executing multiple transactions at a time. It is required to
increase time efficiency. If many transactions try to access the same data, then inconsistency
arises. Concurrency control required to maintain consistency data.
For example, if we take ATM machines and do not use concurrency, multiple persons cannot draw
money at a time in different places. This is where we need concurrency.
QUESTION 6
What is Lost Update problem?
A lost update occurs when two different transactions are trying to update the same column on
the same row within a database at the same time. Typically, one transaction updates a
particular column in a particular row, while another that began very shortly afterward did
not see this update before updating the same value itself. The result of the first transaction is
then "lost," as it is simply overwritten by the second transaction.
QUESTION 7
Explain validation-Based Protocol.
Validation phase is also known as optimistic concurrency control technique. In the validation based
protocol, the transaction is executed in the following three phases:
1. Read phase: In this phase, the transaction T is read and executed. It is used to read the
value of various data items and stores them in temporary local variables. It can perform all
the write operations on temporary variables without an update to the actual database.
2. Validation phase: In this phase, the temporary variable value will be validated against the
actual data to see if it violates the serializability.
3. Write phase: If the validation of the transaction is validated, then the temporary results are
written to the database or system otherwise the transaction is rolled back.
ASSIGNMENT OF UNIT 6
Subject Teacher:
Mrs Parvesh
QUESTION 1
What do you mean by research?
Research data can be generated for different purposes and through different processes.
Simulation data is generated from test models where model and metadata are
more important than output data. For example, climate models and economic
models.
QUESTION 2
QUESTION 3
Explain Quantitative data Analysis
Qualitative data can be observed and recorded. This data type is non-numerical in nature.
This type of data is collected through methods of observations, one-to-one interviews,
conducting focus groups, and similar methods. Qualitative data in statistics is also known as
categorical data – data that can be arranged categorically based on the attributes and
properties of a thing or a phenomenon.
For example, think of a student reading a paragraph from a book during one of the class
sessions. A teacher who is listening to the reading gives feedback on how the child read that
paragraph. If the teacher gives feedback based on fluency, intonation, throw of words, clarity
in pronunciation without giving a grade to the child, this is considered as an example of
qualitative data.
It’s pretty easy to understand the difference between qualitative and quantitative data.
Qualitative data does not include numbers in its definition of traits, whereas quantitative data
is all about numbers.
For a market researcher, collecting qualitative data helps in answering questions like, who
their customers are, what issues or problems they are facing, and where do they need to focus
their attention, so problems or issues are resolved.
Qualitative data is about the emotions or perceptions of people, what they feel. In
quantitative data, these perceptions and emotions are documented. It helps the market
researchers understand the language their consumers speak and deal with the problem
effectively and efficiently.
QUESTION 4
Social research refers to the study of individuals and societies and is often used
to identify regularly occurring social patterns in social life. It can be defined as
the systematic understanding of social facts or phenomena. It is used to gather
information on the social world, in order to come up with a course of action or
simply to develop new knowledge.
Increases the Welfare of Humanity: Most social science studies are conducted with the
objective of enhancing the welfare of humanity.
Can Predict Behavior: Social research helps us understand different people
and societies. Information gathered from social research can help us predict the
behaviour of certain individuals or groups. When we have a good understanding
of a social phenomenon, we may have a better idea of how to govern or guide
it.
Helps Expand or Rectify Current Knowledge: Social research adds to the
knowledge we currently have, and can also be used to test or very old social
fact or beliefs.
Provides an Understanding of Social Life: Social research is used to gather
information on social phenomena. It provides us with an understanding of the
social life of different groups of individuals.
Structural Changes: Social research can be used to bring planned structural
changes to social life.
Precipitates Social Progress: Social research helps us obtain appropriate and
reliable knowledge on social structures and social groups. This information can
be used to disintegrate prejudices, misconceptions, and superstitions,
precipitating social progress and creating a more inclusive society.
Formulates New Theories: Social research allows us to formulate new theories
in different fields of study. There are many existing theories on leadership,
motivation, and human behaviour that wouldn’t exist if it wasn’t for social
research.
Helps Develop Methodologies: Social research has been used over time to
create methodologies to deal with social problems such as drug addiction,
worker ethic, leadership style, child labour, and is continually used to revise old
methodologies or to create new ones.