MTP Solution
MTP Solution
MTP Solution
GENERAL INSTRUCTIONS:
1. Attempt all parts.
2. Be precise in your answers.
3. Answer the questions considering the word limit.
COURSE OUTCOMES
CO1. To describe basic database concepts and architecture, understand the use of database languages in
implementing data related system and data modelling using ER diagram, utilize the concepts of keys while
creating database.
CO2. To create the structure and operation of the relational data model and construct simple and moderately
advanced database queries using Structured Query Language (SQL).
CO3. To implement and successfully apply logical database design principles, make use of functional
dependencies and database normalization.
CO4. To identify the concept of a database transaction, including concurrency control, backup and recovery
and data object locking and protocols. Describe advanced database topic, such as distributed database
systems.
CO5. To explain the concurrency control mechanisms and locking techniques and analyze the case study of
oracle.
SECTION-A
1. Answer all parts. All parts carry equal marks. Write answer of each part in short.
(In one word to approx. 30 words) (2×10=20)
(b) Compute the closure of (AC)+ of a relation R(A,B,C,D,E,F) from the set of Functional
dependency F=( A->B, BC->D, C->E, CD->F) (CO3)
Ans.
(c) Explain 4NF and BCNF. (CO3)
Ans. BCNF stands for “Boyce-Codd Normal Form”. This normal form also known as
the 3.5 Normal form of database normalization. To achieve BCNF, the database must
be already achieved to third normal form. Then following steps should be done to
achieve the BCNF.
• If the database is already in third normal form, next step should be to remove
the multi-valued dependencies.
• (If one or more rows imply the presence of one or more other rows in the same
table, it is called multi-valued dependency.)
• Binary Locks − A lock on a data item can be in two states; it is either locked or
unlocked.
An index, as you would expect, is a data structure that the database uses to find
records within a table more quickly.
CREATE INDEX <indexname> ON <tablename> (<column>, <column>...);
Ans. Triggers are stored programs, which are automatically executed or fired when
some events occur.
Triggers are written to be executed in response to any of the following events
• A database operation
A cursor is a pointer to this context area. PL/SQL controls the context area through a
cursor. A cursor holds the rows (one or more) returned by a SQL statement. The set of
rows the cursor holds is referred to as the active set
Ans. Relational data model is the primary data model, which is used widely around
the world for data storage and processing.
This model is simple and it has all the properties and capabilities required to process
data with storage efficiency.
It is a technique or way of structuring data using relations, which are grid-like
mathematical structures consisting of columns and rows.
Codd proposed the relational model for IBM.
SECTION-B
Note: Attempt any five questions from this section. (In approx. 250 words) (10×5=50)
Decomposition is lossy if R1 ⋈ R2 ⊃ R
Decomposition is lossless if R1 ⋈ R2 = R
STEP1: Put α where there are attributes present for each R1, R2, R3.
A B C D E F
R1 Α α Α
R2 Α α α
R3 α α
STEP2: Check for all dependencies. Left attribute should be two times occurring and right side
attribute should be occurring one time at least.
A B C D E F
R1 Α α Α
R2 Α α α
R3 Α α α
STEP3: Check for all dependencies again. There are no changes at this step.
A B C D E F
R1 Α α Α
R2 Α α α
R3 Α α α
Q (4) Describe in detail timestamp ordering protocol and Thomas’ write rule. (CO4)
Ans. Every transaction has a timestamp associated with it, and the ordering is
determined by the age of the transaction.
A transaction created at 0002 clock time would be older than all other transactions
that come after it.
For example, any transaction 'y' entering the system at 0004 is two seconds younger
and the priority would be given to the older one.
The timestamp-ordering protocol ensures serializability among transactions in their
conflicting read and write operations.
This is the responsibility of the protocol system that the conflicting pair of tasks
should be executed according to the timestamp values of the transactions.
Ans. Constraints enforce limits to the data or type of data that can be
inserted/updated/deleted from a table. The whole purpose of constraints is to maintain
the data integrity during an update/delete/insert into a table. In this tutorial we will
learn several types of constraints that can be created in RDBMS.
Types of constraints
• NOT NULL
• UNIQUE
• DEFAULT
• CHECK
• Domain constraints
• Mapping constraints
NOT NULL:
NOT NULL constraint makes sure that a column does not hold NULL value. When we
don’t provide value for a particular column while inserting a record into a table, it
takes NULL value by default. By specifying NULL constraint, we can be sure that a
particular column(s) cannot have NULL values.
Example:
CREATE TABLE STUDENT(
ROLL_NO INT NOT NULL,
UNIQUE:
The DEFAULT constraint provides a default value to a column when there is no value
provided while inserting a record into a table.
This constraint is used for specifying range of values for a particular column of a table.
When this constraint is being set on a column, it ensures that the specified column
must have the value falling in the specified range.
Key constraints:
PRIMARY KEY:
Primary key uniquely identifies each record in a table. It must have unique values and
cannot contain nulls
Domain constraints:
Each table has certain set of columns and each column allows a same type of data,
based on its data type. The column does not accept values of any other data type.
Mapping Cardinality:
One to One: An entity of entity-set A can be associated with at most one entity of
entity-set B and an entity in entity-set B can be associated with at most one entity of
entity-set A.
One to Many: An entity of entity-set A can be associated with any number of entities
of entity-set B and an entity in entity-set B can be associated with at most one entity of
entity-set A.
Many to One: An entity of entity-set A can be associated with at most one entity of
entity-set B and an entity in entity-set B can be associated with any number of entities
of entity-set A.
Many to Many: An entity of entity-set A can be associated with any number of entities
of entity-set B and an entity in entity-set B can be associated with any number of
entities of entity-set A.
Q (6) What is the use of cursor in PL/SQL explain its types. (CO2)
Ans. A cursor is a temporary work area (CONTEXT AREA) created in the system memory
when a SQL statement is executed.
1. A cursor contains information on a select statement and the rows of data accessed by
it.
2. This temporary work area is used to store the data retrieved from the database, and
manipulate this data.
3. A cursor can hold more than one row, but can process only one row at a time.
4. The set of rows the cursor holds is called the active set.
Implicit cursors
These are created by default when DML statements like, INSERT, UPDATE, and DELETE
statements are executed. They are also created when a SELECT statement that returns just
one row is executed.
Explicit cursors
They must be created when you are executing a SELECT statement that returns more than
one row. Even though the cursor stores multiple records, only one record can be processed
at a time, which is called as current row. When you fetch a row the current row position
moves to next row.
Both implicit and explicit cursors have the same functionality, but they differ in the way
they are accessed.
• Oracle provides few attributes called as implicit cursor attributes to check the status
of DML operations.
• For example, When you execute INSERT, UPDATE, or DELETE statements the cursor
attributes tell us whether any rows are affected and how many have been affected.
When a SELECT... INTO statement is executed in a PL/SQL Block, implicit cursor
attributes can be used to find out whether any row has been returned by the SELECT
statement.
• The status of the cursor for each of these attributes are defined in the below table.
Basic difference between file system and DBMS is given in the below table.
Advantage of DBMS over file system
There are several advantages of Database management system over file system.
Few of them are as follows:
• Data Isolation: Because data are scattered in various files, and files may
be in different formats, writing new application programs to retrieve the
appropriate data is difficult.
• Duplication of data – Redundant data
• Dependency on application programs – Changing files would lead to
change in application programs.
This problem occurs when two transactions, accessing the same data
items, have their operations interleaved in such a way, that one
transaction will access the data before the other has applied any
updates.
2. UNCOMMITTED DATA :
• This problem occurs when one transaction updates a data item,
but has not yet committed the data permanently to the
database.
• Because of failure, the transaction is rolled back and the data
item is returned to its previous value.
• A second transaction accesses the updated data item before it is
returned to its original value.
3. INCONSISTENT DATA:
SECTION-C
Note: Attempt any two questions from this section. (In approx. 400 words) (15×2=30)
Q (10) Illustrate in detail distributed database. Explain fragmentation. (CO4)
Ans.
• The DDBMS synchronizes all the data periodically and ensures that updates
and deletes performed on the data at one location will be automatically reflected
in the data stored elsewhere.
FRAGMENTATION:- VERTICAL
FRAGMENTATION FRAGMENTATION
HORIZONTAL
FRAGMENTATION
5. Applications are classified as those that do not require data from other sites
(local Applications) and those that do require data from other sites (global
applications). We require a DDBMS to have at least one global application.
Types of Fragmentation –
It is not necessary for every site in the system to have its own local database, as
illustrated by the topology of the DDBMS shown in figure.
Replicating Data
• You can create replicas of data at the various sites of a distributed database to
make access to data faster for local clients.
TRANSPARENCY IN DDBMS:-
1. The functionality of a distributed database system must be provided
in such a manner that the complexities of the distributed database
are transparent to both the database users and the database
administrators.
3. Location transparency exists if a user can refer to the same table the
same way, regardless of the node to which the user connects.
4. Location transparency is beneficial for the following reasons:
Q (11) Consider the Relational Schema R(A<B,C,D,E,F,G,H,I,J,) and a set of following functional
dependencies. F={AB->C, A->DE, B->F, F->GH, D->IJ}
Determine the Keys of R?
Decompose R into 2nd Normal Form. (CO3)
Ans.
First find the keys by closure:
DESCRIPTION :
• We can make one by allowing data items to be of various sizes and defining a hierarchy
of data granularities, where the small granularities are nested within larger ones.
• A nonleaf node of the multiple-granularity tree represents the data associated with its
descendants.
• In the tree protocol, each node is an independent data item.
• As an illustration, consider the tree of Figure, which consists of four levels of nodes.
• Below it are nodes of type area; the database consists of exactly these areas.
• Each area contains exactly those files that are its child nodes. No file is in more than
one area.
• As before, the file consists of exactly those records that are its child nodes, and no
record can be present in more than one file.
• As we did in the two-phase locking protocol, we shall use shared and exclusive lock
modes.
• When a transaction locks a node, in either shared or exclusive mode, the transaction
also has implicitly locked all the descendants of that node in the same lock mode.