Solutions To DBMS Assignment II R13
Solutions To DBMS Assignment II R13
ENGINEERING
VALASAPALLE(P), PUNGANUR ROAD, MADANAPALLE 517325
ASSIGNMENT - II
Due Date : 9th April, 2016
1. What are the demerits of relational database design. Describe the problems
caused by redundancy. (Raghu ramakrishnan Pg.No.418, Sudarsan Korth
Pg.No: 258,Ullman 102-103).
Pitfalls in Relational-Database Design
Among the undesirable properties that a bad design may have are:
Repetition of information
Inability to represent certain information
Problems Caused by Redundancy
Storing the same information redundantly, that is, in more than one place within a
database, can lead to several problems:
Redundant storage: Some information is stored repeatedly.
Update anomalies: If one copy of such repeated data is updated, an inconsistency
is created unless all copies are similarly updated.
Insertion anomalies: It may not be possible to store some information unless some
other information is stored as well.
Deletion anomalies: It may not be possible to delete some information without
losing some other information as well.
2. Define Normalization and explain about the properties of decomposition.
(Raghu ramakrishnan Pg.No.419,434,Korth Pg.No: 274-282).
Database normalization is the process of making the data in a database available
in the most organized way possible.When youre normalizing a database, there are
two things you need to consider: whether the information in the database has
internal redundancies, and whether the dependencies across the different tables in
the database are logically organized.The term normalization comes from the
concept of normal forms, which describe just how organized the information is in
the database. As an example, lets imagine were creating a database of the
children in a class, and the pets they have. When starting to build this database,
the first approach might be to create a simple table with all of the information in
one place, and one row for each student.
ADITYA COLLEGE OF
ENGINEERING
VALASAPALLE(P), PUNGANUR ROAD, MADANAPALLE 517325
| Name
---------------------------------------------| Heather
| 10
| Dog | Rex
---------------------------------------------| Rachel
| 10
| Cat | Fluff
---------------------------------------------| Jimmy
| 11
| Dog | Kimba
---------------------------------------------| Lola
| 1o
| Cat | Thomas
----------------------------------------------
| Name
----------------------------------------------
ADITYA COLLEGE OF
ENGINEERING
VALASAPALLE(P), PUNGANUR ROAD, MADANAPALLE 517325
| 10
| Dog | Rex
---------------------------------------------| Heather
| 10
| Cat | Thomas
---------------------------------------------| Rachel
| 10
| Cat | Fluff
---------------------------------------------| Jimmy
| 11
| Dog | Kimba
---------------------------------------------| Lola
| 10
| Cat | Thomas
----------------------------------------------
| Name
| Age |
----------------------------| Heather
| 10
----------------------------| Rachel
| 10
-----------------------------
ADITYA COLLEGE OF
ENGINEERING
VALASAPALLE(P), PUNGANUR ROAD, MADANAPALLE 517325
| 11
----------------------------| Lola
| 10
-----------------------------
TABLE: PETS
| Type
| Pet Name
| Owner
--------------------------------------| Dog
| Rex
| Heather
--------------------------------------| Cat
| Thomas
| Heather
--------------------------------------| Cat
| Fluff
| Rachel
--------------------------------------| Dog
| Kimba
| Jimmy
--------------------------------------| Cat
| Thomas
| Lola
---------------------------------------
ADITYA COLLEGE OF
ENGINEERING
VALASAPALLE(P), PUNGANUR ROAD, MADANAPALLE 517325
| ID | Name
| Age |
---------------------------------| 00 | Heather
| 10
---------------------------------| 01 | Rachel
| 10
---------------------------------| 02 | Jimmy
| 11
---------------------------------| 03 | Lola
| 10
----------------------------------
TABLE: PETS
| ID | Type
| Pet Name
| Owner ID |
--------------------------------------------
ADITYA COLLEGE OF
ENGINEERING
VALASAPALLE(P), PUNGANUR ROAD, MADANAPALLE 517325
| Rex
| 00
-------------------------------------------| 01 | Cat
| Thomas
| 00
-------------------------------------------| 02 | Cat
| Fluff
| 01
-------------------------------------------| 03 | Dog
| Kimba
| 02
-------------------------------------------| 04 | Cat
| Thomas
| 03
--------------------------------------------
| ID | Name
| Age |
---------------------------------| 00 | Heather
| 10
---------------------------------| 01 | Rachel
| 10
ADITYA COLLEGE OF
ENGINEERING
VALASAPALLE(P), PUNGANUR ROAD, MADANAPALLE 517325
| 11
---------------------------------| 03 | Lola
| 10
----------------------------------
TABLE: PETS
| ID | Type
| Pet Name
--------------------------------| 00 | Dog
| Rex
--------------------------------| 01 | Cat
| Thomas
--------------------------------| 02 | Cat
| Fluff
--------------------------------| 03 | Dog
| Kimba
---------------------------------
Table: PETS-STUDENTS
| Pet ID | Owner ID |
ADITYA COLLEGE OF
ENGINEERING
VALASAPALLE(P), PUNGANUR ROAD, MADANAPALLE 517325
| 00
--------------------| 01
| 00
--------------------| 02
| 01
--------------------| 03
| 02
--------------------| 01
| 03
---------------------
Now we have a flexible and searchable structure in fourth normal form that can
represent all the available information about each of the students, each of the
pets, and the relationships among them.
3. Define Functional Dependency and closure of a functional dependency.
Describe various rules of closure of functional dependencies. (Raghu
ramakrishnan Pg.No.422-430 ,Ullman Pg.No. 83-84,90-95 Sudarsan Korth
Pg.No: 263).
Functional dependency is a relationship that exists when one attribute uniquely
determines another attribute. If R is a relation with attributes X and Y, a functional
dependency between the attributes is represented as X->Y, which specifies Y is
functionally dependent on X.
Closure of a Functional Dependency Set F, F+: If F is a set of functional
dependencies for a relation R, the set. of functional dependencies that can be
derived from F, F+, is called the CLOSURE of F. Amstrong's axiom are sufficient to
compute all of F+.
1. To compute
ADITYA COLLEGE OF
ENGINEERING
VALASAPALLE(P), PUNGANUR ROAD, MADANAPALLE 517325
, then
holds.
holds, and
holds, then
holds.
2. These rules are sound because they do not generate any incorrect functional
dependencies. They are also complete as they generate all of
.
3. To make life easier we can use some additional rules, derivable from Armstrong's
Axioms:
o Union rule: if
and
o Decomposition rule: if
o Pseudotransitivity rule: if
, then
holds, then
holds, and
holds.
and
both hold.
holds, then
holds.
Relational database systems are expected to be equipped with a query language that can assist
its users to query the database instances. There are two kinds of query languages relational
algebra and relational calculus.
Relational Algebra
Relational algebra is a procedural query language, which takes instances of relations as input
and yields instances of relations as output. It uses operators to perform queries. An operator can
be either unary or binary. They accept relations as their input and yield relations as their
output. Relational algebra is performed recursively on a relation and intermediate results are
also considered relations.
ADITYA COLLEGE OF
ENGINEERING
VALASAPALLE(P), PUNGANUR ROAD, MADANAPALLE 517325
Select
Project
Union
Set different
Cartesian product
Rename
Select Operation
It selects tuples that satisfy the given predicate from a relation.
Notation pr r
Where stands for selection predicate and r stands for relation. p is prepositional logic formula
which may use connectors like and, or, and not. These terms may use relational operators like
=, , , < , >, .
For example
subject
(Books)
= "database"
(Books)
Output Selects tuples from books where subject is 'database' and 'price' is 450.
subject
(Books)
Output Selects tuples from books where subject is 'database' and 'price' is 450 or those books
published after 2010.
Project Operation
ADITYA COLLEGE OF
ENGINEERING
VALASAPALLE(P), PUNGANUR ROAD, MADANAPALLE 517325
author
(Books)
Selects and projects columns named as subject and author from the relation Books.
Union Operation
It performs binary union between two given relations and is defined as
r s = { t | t r or t s}
Notion r U s
Where r and s are either database relations or relation result set
temporaryrelation temporaryrelation .
For a union operation to be valid, the following conditions must hold
author
(Books)
author
(Articles)
Output Projects the names of the authors who have either written a book or an article or
both.
Set Difference
The result of set difference operation is tuples, which are present in one relation but are not in
the second relation.
ADITYA COLLEGE OF
ENGINEERING
VALASAPALLE(P), PUNGANUR ROAD, MADANAPALLE 517325
author
(Books)
author
(Articles)
Output Provides the name of authors who have written books but not articles.
Cartesian Product X
Combines information of two different relations into one.
Notation r s
Where r and s are relations and their output will be defined as
r s = { q t | q r and t s}
author
(Books Articles)
= 'tutorialspoint'
Output Yields a relation, which shows all the books and articles written by tutorialspoint.
Rename Operation
The results of relational algebra are also relations but without any name. The rename operation
allows us to rename the output relation. 'rename' operation is denoted with small Greek letter
rho .
Notation x E E
Where the result of expression E is saved with name of x.
Additional operations are
Set intersection
Assignment
Natural join
Relational Calculus
ADITYA COLLEGE OF
ENGINEERING
VALASAPALLE(P), PUNGANUR ROAD, MADANAPALLE 517325
Output Returns tuples with 'name' from Author who has written article on 'database'.
TRC can be quantified. We can use Existential and Universal Quantifiers .
For example
{ R| T
Output The above query will yield the same result as the previous one.
ADITYA COLLEGE OF
ENGINEERING
VALASAPALLE(P), PUNGANUR ROAD, MADANAPALLE 517325