DBMS Solved QP
DBMS Solved QP
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 :
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
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)
Need for normalization : 1) It eliminates redundant data.
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.
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.
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 :- Timestamp based Protocol :-
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) is the largest timestamp of any transaction that executed write(X) successfully.
R_TS(X) is the largest timestamp of any transaction that executed read(X) successfully.
3) TYPES OF NOSQL :
ANS :- There are four types of NoSQL databases are :-
1. Key-value store :
Key-value pair is the simplest type of NoSQL database.
It is designed in such a way to handle lots of data and heavy load.
In the key-value storage the key is unique and the value can be JSON, string or
Binary objects.
For example -
{Customer:
[
{“id”:1, “name”:”Ankita”},
{“id”:2,”name”:”Kavita”}
]
}
2. Document store :
The document store make use of key-value pair to store and retrieve data.
The document is stored in the form of XML and JSON.
The document stores appear the most natural among NoSQL
database types.
It is most commonly used due to flexibility and ability to query
on any field.
For example -
3. Graph based :
The graph database is typically used in the applications where the relationships
among the data elements is an important aspect.
The connections between elements are called links or relationships. In a graph
database, connections are first-class elements of the database, stored directly. In relational
databases, links are implied, using data to express the relationships.
The graph database has two components -
1) Node : The entities itself. For example - People, student,
2) Edge : The relationships among the entities.
For example -
4. Wide column store :
Wide column store model is similar to traditional relational database. In this model,
the columns are created for each row rather than having predefined by the table
structure.
In this model number of columns are not fixed for each record.
Columns databases can quickly aggregate the value of a given column.
For example -
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
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) CAP Theorem :-
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) Active Databases :-
Active databases are the databases which consists of triggers. The situation and
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.
Generalized Model for Active Database :
The general model for active database is considered as Event-Condition-Action(ECA)
model. This model has three components :
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) Deductive Database :-
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>
</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)