0% found this document useful (0 votes)
25 views

DBMS ENDSEM Solved Question Paper

Uploaded by

shantanubhise118
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

DBMS ENDSEM Solved Question Paper

Uploaded by

shantanubhise118
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

SPPU_TE_BE_COMP

Q.1 1) ANS :
 1NF:
The first normal form rule defines that all the attributes in a relation must have atomic
domains. The values in an atomic domain are indivisible units.
The table is said to be in 1NF if it follows following rules -
i) It should only have single (atomic) valued attributes/columns.
ii) Values stored in a column should be of the same domain.
iii) All the columns in a table should have unique names.
iv) And the order in which data is stored, does not matter.
Example :-

As there are multiple values of phone number for sid 1 and 3, the above table is not in
1NF. We can make it in 1NF. The conversion is as follows -

 2NF:
For a table to be in the Second Normal Form, following conditions must be followed
i) It should be in the First Normal form.
ii) It should not have partial functional dependency.
Example :- Consider following table in which every information about a the
Student is maintained in a table such as student id(sid), student name(sname), course
id(cid) and course name(cname).
Step 1 : The above table is in 1NF.
Step 2 : Here sname and sid are associated similarly cid and cname are associated with
each other. Now if we delete a record with sid = 2, then automatically the course C++ will
also get deleted. Thus,
sid->sname or cid->cname is a partial functional dependency, because {sid,cid} should
be essentially a candidate key for above table. Hence to bring the above table to 2NF we
must decompose it as follows :

STUDENT : COURSE :
SPPU_TE_BE_COMP

Study material provided by: Vishwajeet Londhe

Join Community by clicking below links

Telegram Channel

https://t.me/SPPU_TE_BE_COMP
(for all engineering Resources)

WhatsApp Channel
(for all tech updates)

https://whatsapp.com/channel/0029ValjFriICVfpcV9HFc3b

Insta Page
(for all engg & tech updates)

https://www.instagram.com/sppu_engineering_update
SPPU_TE_BE_COMP
 3NF :-
A table is said to be in the third normal form when,
i) It is in the second normal form.(i.e. it does not have partial functional dependency).
ii) It doesn't have transitive dependency.
A table is in 3NF if it is in 2NF and for each functional dependency i.e X-> Y
at least one of the following conditions hold :
i) X is a super key of table.
ii) Y is a prime attribute of table.
Example :- Student_details table

Student Zip

 BCNF :
Boyce and Codd Normal Form is a higher version of the Third Normal form. This
form deals with certain type of anomaly that is not handled by 3NF.
A 3NF table which does not have multiple overlapping candidate keys is said to be in
BCNF.
For a table to be in BCNF, following conditions must be satisfied :
i) R must be in 3rd Normal Form
ii) For each functional dependency ( X → Y ), X should be a super key. In simple words
if Y is a prime attribute then X can not be non prime attribute.
Example :- Enrollment table
SPPU_TE_BE_COMP
Student Course

 Normalization :-
Normalization is the process of reorganizing data in a database so that it meets two
basic requirements :
1) There is no redundancy of data (all data is stored in only one place) and
2) Data dependencies are logical (all related data items are stored together)
 Needfornormalization:1)Iteliminatesredundantdata.
2) It reduces chances of data error.
3) The normalization is important because it allows database to take up less disk space.
4) It also help in increasing the performance.
5) It improves the data integrity and consistency.

2) CODD’S 12 RULES
ANS :- Codd proposed 13 rules for relational database management system, which are
popularly known as Codd’s 12 rule : These rules are as follows –
Rule 0 : This rule states for a database to be relational, it must use its relational capabilities
to manage the database.
Rule 1 : The Information rule - All information in an RDBMS is represented logically only
by storing the values in tables.
Rule 2 : The Guaranteed Access rule - Each item of data in an RDBMS is guaranteed to be
logically accessible by specifying the table name, primary key value, and column name.
Rule 3 : The Systematic Treatment of Null Values rule - Null values are supported in a
fully relational DBMS for representing missing information or inapplicable information in
a systematic way which is independent of the data type.
Rule 4 : The Dynamic Online Catalog Based on the Relational Model rule - Database
dictionary which is called as catalog-is the structure description of the complete Database
and it must be stored online. This Catalog must be governed by same rules as rest of the
database. The same query language should be used on catalog as used to query database.
SPPU_TE_BE_COMP
Rule 5 : The Comprehensive Data Sublanguage rule - At least one well structured, well
defined language must be there which can access all the data present in the database.
Rule 6 : The View Updating rule - All views of the data which are theoretically updatable
must be updatable in practice by the DBMS.
Rule 7 : Relational level operation - The High-level Insert, Update, and Delete rule: There
must be insert, delete and update operations at each level of relations.
Rule 8 : The Physical Data Independence rule - Physical storage should not matter the
system. Whenever any changes are made in either storage representations or access
methods then it should not affect the application.
Rule 9 : The Logical Data Independence rule - If any changes are made in table structure
then the logical view of the user should not get affected. Fpr Rule example - if a table is
split into two tables internally, the view of the table to the user should be an entire table
and not the split tables.
Rule 10 : The Integrity Independence rule - The Integrity constraints must be defined by
the RDBMS stored in the system and it should not be enforced by the external application
programs.
Rule 11 : The Distribution Independence rule - An RDBMS must have distribution
independence. That means, even if database is scattered geographically, user should get a
feel as if it is stored in one piece at one location.
Rule 12 : The Non-sub-version rule - If low-level language is allowed to access the
system, then that low-level language must not be able to subvert or bypass the integrity
rules which are expressed in a higher-level language.

3) What is the impact of insert, update and delete anomaly on overall design of
database ? How normalization is used to remove these anomalies ? ANS ;-
Database anomalies are the faults in the database caused due to poor management of storing
everything in the flat database. It can be removed with the process of Normalization, which
generally splits the database which results in reducing the anomalies in the database.
Insertion Anomaly : If a tuple is inserted in referencing relation and referencing attribute value
is not present in referenced attribute, it will not allow insertion in referencing relation.
Example : If we try to insert a record in STUDENT_COURSE with STUD_NO =7, it will not allow
it. IMPACT :- These anomalies occur when it is not possible to insert data into a database
because the required fields are missing or because the data is incomplete. For example, if a
database requires that every record has a primary key, but no value is provided for a particular
record, it cannot be inserted into the database. Deletion and Updation Anomaly : If a tuple is
deleted or updated from referenced relation and the referenced attribute value is used by
referencing attribute in referencing relation, it will not allow deleting the tuple from referenced
relation. Example : If we want to update a record from STUDENT_COURSE with STUD_NO =1,
We have to update it in both rows of the table. If we try to delete a record from STUDENT with
STUD_NO =1, it will not allow it.
IMPACT :- DELETE :- These anomalies occur when deleting a record from a database and can
result in the unintentional loss of data. For example, if a database contains information about
customers and orders, deleting a customer record may also delete all the orders associated
with that customer.
SPPU_TE_BE_COMP
UPDATE :- These anomalies occur when modifying data in a database and can result in
inconsistencies or errors. For example, if a database contains information about employees
and their salaries, updating an employee’s salary in one record but not in all related records
could lead to incorrect calculations and reporting.
Removal of Anomalies :-
These anomalies can be avoided or minimized by designing databases that adhere to the
principles of normalization. Normalization involves organizing data into tables and applying
rules to ensure data is stored in a consistent and efficient manner. By reducing data
redundancy and ensuring data integrity, normalization helps to eliminate anomalies and
improve the overall quality of the database.
Q.2. 1) Suppose a transaction , issues a read command on data item Q. How time -
stamp based protocol decides whether to allow the operation to be executed or not
using time-stamp based protocol of concurrency control.
ANS:- TimestampbasedProtocol:-
The main idea for this protocol is to order the transactions based on their Timestamps. A
schedule in which the transactions participate is then serializable and the only equivalent
serial schedule permitted has the transactions in the order of their Timestamp Values. Stating
simply, the schedule is equivalent to the particular Serial Order corresponding to the order of
the Transaction timestamps. An algorithm must ensure that, for each item accessed by
Conflicting Operations in the schedule, the order in which the item is accessed does not
violate the ordering. To ensure this, use two Timestamp Values relating to each database
item X.
 W-_TS(X)isthelargesttimestampofanytransactionthatexecutedwrite(X)successfully.
 R_TS(X)isthelargesttimestampofanytransactionthatexecutedread(X)successfully.
Stamp based protocol decides Time-stamp based protocol of concurrency control :-
Every transaction is issued a timestamp based on when it enters the system. Suppose, if an
old transaction Ti has timestamp TS(Ti), a new transaction Tj is assigned timestamp TS(Tj)
such that TS(Ti) < TS(Tj). The protocol manages concurrent execution such that the
timestamps determine the serializability order. The timestamp ordering protocol ensures that
any conflicting read and write operations are executed in timestamp order. Whenever some
Transaction T tries to issue a R_item(X) or a W_item(X), the Basic TO algorithm compares
the timestamp of T with R_TS(X) & W_TS(X) to ensure that the Timestamp order is not
violated. This describes the Basic TO protocol in the following two cases.
1. Whenever a Transaction T issues a W_item(X) operation, check the following conditions:
If R_TS(X) > TS(T) and if W_TS(X) > TS(T), then abort and rollback T and reject the
operation. else,
Execute W_item(X) operation of T and set W_TS(X) to TS(T).
2. Whenever a Transaction T issues a R_item(X) operation, check the following conditions:
If W_TS(X) > TS(T), then abort and reject T and reject the operation, else
If W_TS(X) <= TS(T), then execute the R_item(X) operation of T and set R_TS(X) to the
larger of TS(T) and current R_TS(X).
Whenever the Basic TO algorithm detects two conflicting operations that occur in an
incorrect order, it rejects the latter of the two operations by aborting the Transaction that
issued it. Schedules produced by Basic TO are guaranteed to be conflict serializable. Already
discussed that using Timestamp can ensure that our schedule will be deadlock free.
SPPU_TE_BE_COMP
2 ) Explain the concept of conflict serializability with example. Since every conflict-
serializable schedule is view serializable, why do we emphasize conflict serializability
rather than view serializability ?
ANS :- Conflict Serializability :-
Suppose T1 and T2 are two transactions and I1 and I2 are the instructions in
T1 and T2 respectively. Then these two transactions are said to be conflict serializable, if
both the instruction access the data item d, and at least one of the instruction is write
operation.
What is conflict : In the definition three conditions are specified for a conflict in
conflict serializability -
1) There should be different transactions
2) The operations must be performed on same data items
3) One of the operation must be the Write (W) operation.
We can test a given schedule for conflict serializability by constructing a precedence
graph for the schedule, and by searching for absence of cycles in the graph.
Predence graph is a directed graph, consisting of G = (V,E) where V is set of vertices
and E is set of edges. The set of vertices consists of all the transactions participating
in the schedule. The set of edges consists of all edges Ti Tj
for which one of three
conditions holds : 1. Ti executes write(Q) before Tj
executes read(Q). 2. Ti executes read(Q) before Tj
executes write(Q). 3. Ti executes write(Q) before Tj
executes write(Q).
A serializability order of the transactions can be obtained by finding a linear order
consistent with the partial order of the precedence graph. This process is called topological
sorting.
View Serializability :-
If a given schedule is found to be view equivalent to some serial schedule, then it is called as a
view serializable schedule. View Equivalent Schedule :- Consider two schedules S1 and S2
consisting of transactions T1 and T2 respectively, then schedules S1 and S2 are said to be
view equivalent schedule if it satisfies following three conditions : 
IftransactionT1readsadataitemAfromthedatabaseinitiallyinscheduleS2, then in schedule S2
also, T1 must perform the initial read of the data item X from
the database. This is same for all the data items. In other words - the initial reads
must be same for all data items.
 IfdataitemAhasbeenupdatedatlastbytransactionTiinscheduleS1,thenin
schedule S2 also, the data item A must be updated at last by transaction Ti.
 IftransactionTireadsadataitemthathasbeenupdatedbythetransactionTjin
schedule S1, then in schedule S2 also, transaction Ti must read the same data item
that has been updated by transaction Tj. In other words the Write-Read sequence
must be same.
EXPLAINATION :- Every conflict serializable is view serializable & Every view
serializable schedule is not necessarily conflict serializable. It is complex to test view
serializability and It is easy to test conflict serializability so we emphasize conflict
serilizability rather than view serilizability.
SPPU_TE_BE_COMP
3) State and explain in brief the ACID properties. During execution of transaction, a
transaction passes through several states, until it finally commits or aborts. List all
possible sequences of states through which a transaction may pass. Explain why
each state transition occurs. ANS :- 1) Atomicity :

This property states that each transaction must be considered as a single unit and
must be completed fully or not completed at all.
 No transaction in the database is left half completed.
 Database should be in a state either before the transaction execution or after the
transaction execution. It should not be in a state ‘executing’.
 For example - In above mentioned withdrawal of money transaction all the five
steps must be completed fully or none of the step is completed. Suppose if
transaction gets failed after step 3, then the customer will get the money but the
balance will not be updated accordingly. The state of database should be either at
before ATM withdrawal (i.e customer without withdrawn money) or after ATM
withdrawal (i.e. customer with money and account updated). This will make the
system in consistent state.
2) Consistency :
 Thedatabasemustremaininconsistentstateafterperforminganytransaction.  For
example : In ATM withdrawal operation, the balance must be updated appropriately
after performing transaction. Thus the database can be in consistent state.
3) Isolation :
 Inadatabasesystemwheremorethanonetransactionarebeingexecuted
simultaneously and in parallel, the property of isolation states that all the transactions
will be carried out and executed as if it is the only transaction in the system. 
Notransactionwillaffecttheexistenceofanyothertransaction.
 Forexample:Ifabankmanagerischeckingtheaccountbalanceofparticular
customer, then manager should see the balance either before withdrawing the
money or after withdrawing the money. This will make sure that each individual
transaction is completed and any other dependent transaction will get the consistent
data out of it. Any failure to any transaction will not affect other transaction in this
case. Hence it makes all the transactions consistent.
4) Durability :
 The database should be strong enough to handle any system failure.
 If there is any set of insert /update, then it should be able to handle and commit to
the database.
 Ifthereisanyfailure,thedatabaseshouldbeabletorecoverittotheconsistent
state.
 Forexample:InATMwithdrawalexample,ifthesystemfailurehappensafter customer
getting the money then the system should be strong enough to update Database with
his new balance, after system recovers. For that purpose the system has to keep the
log of each transaction and its failure. So when the system recovers, it should be able
to know when a system has failed and if there is any pending transaction, then it
should be updated to Database.
SPPU_TE_BE_COMP
Q.3 1) Types of Data : Structured, Unstructured Data and Semi-Structured Data :

2) SQLANDNOSQL:
SQL NOSQL
RELATIONAL DATABASE
Non-relational or distributed database system.
MANAGEMENT SYSTEM (RDBMS)
These databases have fixed or static or
predefined schema They have a dynamic schema
These databases are not suited for hierarchical
data storage. These databases are best suited for hierarchical
These databases are best suited for complex data storage.
queries These databases are not so good for complex
Vertically Scalable queries
Horizontally scalable
Follows ACID property
Follows CAP(consistency, availability, partition
tolerance)
Examples: MySQL, PostgreSQL, Oracle, MS- Examples: MongoDB, HBase, Neo4j,
SQL Server, etc Cassandra, etc

3) TYPES OF NOSQL :
ANS :- There are four types of NoSQL databases are :-
1. Key-value store :
 Key-valuepairisthesimplesttypeofNoSQLdatabase.
 Itisdesignedinsuchawaytohandlelotsofdataandheavyload.
 In the key-value storage the key is unique and the value can be JSON, string or
Binary objects.
 Forexample-
{Customer:
[
SPPU_TE_BE_COMP
{“id”:1, “name”:”Ankita”},
{“id”:2,”name”:”Kavita”}
]
}
2. Document store :
 Thedocumentstoremakeuseofkey-valuepairtostoreandretrievedata.
 ThedocumentisstoredintheformofXMLandJSON.
 The document stores appear the most natural among NoSQL
database types.
 Itismostcommonlyusedduetoflexibilityandabilitytoquery
on any field.
 Forexample-
3. Graph based :
 Thegraphdatabaseistypicallyusedintheapplicationswheretherelationships
among the data elements is an important aspect.
 Theconnectionsbetweenelementsarecalledlinksorrelationships.Inagraph
database, connections are first-class elements of the database, stored directly. In relational
databases, links are implied, using data to express the relationships.
 Thegraphdatabasehastwocomponents-
1) Node : The entities itself. For example - People, student,
2) Edge : The relationships among the entities.
For example -
4. Wide column store :
 Widecolumnstoremodelissimilartotraditionalrelationaldatabase.Inthismodel,
the columns are created for each row rather than having predefined by the table
structure.
 Inthismodelnumberofcolumnsarenotfixedforeachrecord.
 Columnsdatabasescanquicklyaggregatethevalueofagivencolumn.
 Forexample-

4)
BASE Properties :-
 The relational database strongly follow the ACID properties(Atomicity, Consistency,
Isolation and Durability) while the NoSQL database follows BASE properties.
Base properties consists of :

1) Basically Available : It means the system is guaranteed to be available in the event of
failure. 2) Soft State : It means, even without an input the system state may change. 3)
Eventual Consistency : The system will become consistent over time.
Soft State :-
This property refers to the fact that the state of the database can change over time, even
without any explicit user intervention. This can happen due to the effects of background
SPPU_TE_BE_COMP
processes, updates to data, and other factors. The database should be designed to handle this
change gracefully, and ensure that it does not lead to data corruption or loss.
Eventual Consistency Property :-
This property refers to the eventual consistency of data in the database, despite changes over
time. In other words, the database should eventually converge to a consistent state, even if it
takes some time for all updates to propagate and be reflected in the data. This is in contrast to
the immediate consistency required by traditional ACID-compliant databases.
5) CAPTheorem:-

Cap theorem is also called as brewer’s theorem.
The CAP Theorem is comprised of three components (hence its name) as they relate
to distributed data stores :
1.Consistency : All reads receive the most recent write or an error.
2.Availability : All reads contain data, but it might not be the most recent.
3.Partition tolerance : The system continues to operate despite network failures
(i.e.; dropped partitions, slow network connections, or unavailable network
connections between nodes.)
 The CAP theorem states that it is not possible to guarantee all three of the desirable
properties - consistency, availability, and partition tolerance at the same time in a
distributed system with data replication.
6)

Q.4
1) ActiveDatabases:-
 Activedatabasesarethedatabaseswhichconsistsoftriggers.Thesituationand
action rules are embedded in the active databases. The active databases are able to
react automatically to the situations in the database. The trigger is a technique for
specifying certain types of active rules. The commercial databases such as Oracle,
DB2, Microsoft SQLServer allows the use of triggers.
 GeneralizedModelforActiveDatabase:
The general model for active database is considered as Event-Condition-Action(ECA)
model. This model has three components :
SPPU_TE_BE_COMP
i) Event : The events are database update operations that are performed explicitly on
the databases.
ii) Condition : The condition determines whether the rule action should be executed.
If the action is not specified then the action will be executed automatically on
occurrence of the event.
iii) Action : The action is usually a sequence of SQL statements. It could be a database
transaction or external program that will be executed on occurrence of condition.
2) DeductiveDatabase:-
 Deductive database is a database system that can make deductions based on rules
and facts stored in the database.
Deductive databases use the concept of logic programming for specifying the rules

and the facts. Prolog is a popular programming language which is based on the
concept of logic programming.
There are two types of specifications used in deductive databases ;-

1.Facts : Facts are specified as the same way the relations are specified in the
Relational Database except it is not necessary to include the attribute names.The
meaning of an attribute value in a tuple is determined solely by its position in the
tuple. 2. Rules : They specify “virtual relations” that are not actually stored but that
can be formed from the facts by applying deduction mechanisms based on the rule
specifications.
3) XML :-


XML stands for eXtensible Markup Language.


This scripting language is similar to HTML. That means, this scripting language
contains various tags. But these tags are not predefined tags, in-fact user can define
his own tags.
Thus HTML is designed for representation of data on the web page whereas the

XML is designed for transport or to store data.
SIGNIFICANCE of XML :-
1. XML is used to display the meta contents i.e. XML describes the content of the
document.
2. XML is useful in exchanging data between the applications.
3. The data can be extracted from database and can be used in more than one
application. Different applications can perform different tasks on this data.
When to use :-
XML database is used to store large amount of data. Instead of table format, Native XML
database is based on container format. You can query data by XPath expressions.
Native XML database is preferred over XML-enable database because it is highly capable to
store, maintain and query XML documents.
EXAMPLE :-
<bank>
<account>
<account-number> S101 </account-number>
<branch-name> Shivaji Nagar </branch-name>
<balance> 5000 </balance>
SPPU_TE_BE_COMP
</account>
<customer>
<customer-name> Ram Kumar </customer-name>
<customer-street> Fergusson Road</customer-street>
<customer-city> Pune </customer-city>
</customer>
<depositor>
<account-number> S101 </account-number>
<customer-name> RamKumar </customer-name>
</depositor>
</bank>

4)

You might also like