Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

DEPARTMENT OF INFORMATION TECHNOLOGY,CEC LANDRAN

DEPARTMENT OF INFORMATION TECHNOLOGY


PRACTICAL FILE
SUBJECT :- DBMS ASSIGNMENT -2
B. TECH – Vth SEM

CHANDIGARH ENGINEERING COLLEGE


LANDRAN,MOHALI-140307

SUBMITTED TO :- SUBMITTED BY:-


Ms.PAMELA GROVER Jashan Bansal
1703283
B.TECH IT-B1
1703283 Page 1
DEPARTMENT OF INFORMATION TECHNOLOGY,CEC LANDRAN

3. What do you mean by Normalization? What do you mean by Multi-


valued and Join Dependency. Also Explain 4th and 5th Normal forms
with the help of examples.

Ans.Normalization-:It can be defined as a process during which redundant relation


schemas are decomposed by breaking up their attributes into smaller
relation schemas that possess desirable properties.
o Multi-valued Dependency-: Multivalued dependency occurs when two attributes in a
table are independent of each other but, both depend on a third attribute.
o A multivalued dependency consists of at least two attributes that are dependent
on a third attribute that's why it always requires at least three attributes.

Join Dependency-: a join dependency is a constraint on the set of legal relations over
a database scheme. A table is subject to a join dependency if can always be recreated
by joining multiple tables each having a subset of the attributes of . If one of the tables in
the join has all the attributes of the table , the join dependency is called trivial.

Another way to describe a join dependency is to say that the relationships in the join
dependency are independent of each other.

Fourth normal form (4NF) is a level of database normalization where there are no
non-trivial multivalued dependencies other than a candidate key. It builds on the first
three normal forms (1NF, 2NF and 3NF) and the Boyce-Codd Normal Form (BCNF). It
states that, in addition to a database meeting the requirements of BCNF, it must not
contain more than one multivalued dependency.

Example- Consider the database table of a class whaich has two relations R1
contains student ID(SID) and student name (SNAME) and R2 contains course
id(CID) and course name (CNAME).

SID SNAME

S1 A

S2 B

CID CNAME

C1 C

1703283 Page 2
DEPARTMENT OF INFORMATION TECHNOLOGY,CEC LANDRAN

CID CNAME

C2 D

SID SNAME CID CNAME

S1 A C1 C

S1 A C2 D

S2 B C1 C

S2 B C2 D

Fifth Normal Form / Projected Normal Form (5NF):

A relation R is in 5NF if and only if every join dependency in R is implied by the


candidate keys of R. A relation decomposed into two relations must have loss-less
join Property, which ensures that no spurious or extra tuples are generated, when
relations are reunited through a natural join.

Example – Consider the above schema, with a case as “if a company makes a
product and an agent is an agent for that company, then he always sells that product
for the company”. Under these circumstances, the ACP table is shown as:
Table – ACP

AGENT COMPANY PRODUCT

A1 PQR Nut

A1 PQR Bolt

A1 XYZ Nut

A1 XYZ Bolt

A2 PQR Nut

The relation ACP is again decompose into 3 relations. Now, the natural Join of all the three relations will be shown as:

Table – R1

AGENT COMPANY

A1 PQR

A1 XYZ

1703283 Page 3
DEPARTMENT OF INFORMATION TECHNOLOGY,CEC LANDRAN

AGENT COMPANY

A2 PQR

Table – R2

AGENT PRODUCT

A1 Nut

A1 Bolt

A2 Nut

COMPANY PRODUCT

PQR Nut

PQR Bolt

XYZ Nut

XYZ Bolt

Result of Natural Join of R1 and R3 over ‘Company’ and then Natural Join of R13
and R2 over ‘Agent’and ‘Product’ will be table ACP.

4.Normalize the following database upto 3NF:

Student (course_code, CName, TeacherName, Rollno, SName,


Sys_used, Hrly_rate, Total_ Hrs) Also, explain the delete and update
anomalies of 1NF, 2NF and 3NF. How these can be rectified.
[Assumptions: each student studies number of courses, Only one
system is assigned to each student. Cname, Sname stands for
Course name and student name respectively].
Ans.-The above rule calls for breaking this relation into three new relations .The primary
key of STUDENT (course_Code,roll no) and the remaining attributes of this relation that

1703283 Page 4
DEPARTMENT OF INFORMATION TECHNOLOGY,CEC LANDRAN

fully depends on this composite key is Total_Hours .The scheme of this new relation
that we have named HOURS_ASSIGNED is as foloows:

HOURS_ASSIGNED(COURSE_Code,Roll no., Total_Hours)

The second relation contains Roll no as its Primary key,because Rollno fully determine
the Name, System_Used, and Hourly_rate . This scheme is as follows-:

STUDENT_SYSTEM_CHARGE(Rollno,Name ,System _used, Hourly_Rate)

The third relation contains Course_Code as its Primary key,because Course_Code fully
determine the Course_Name,Teacher_Name.The Scheme is as foloows:-

COURSE(course_code,Course_name,Teacher_name)

HOURS_ASSIGNED

Course_code Rollno Total_hrs


C1 100 7
C1 102 3
C1 103 6
C1 100 1
C2 104 7
C2 105 3
C2 101 1
C2 106 2
C3 107 3
C3 108 2
C3 108 1
C4 109 2

STUDENT_SYSTEM_CHARGE

Roll no Name System_used Hourly_rate


100 A1 P-1 20
101 A2 P-2 30
102 A3 CELERON 10
100 A4 P-IV 40
104 A1 P-1 20
105 A5 P-III 35
101 A6 P-IV 30
106 A9 P-V 30
105 A7 P-IV 40
107 A8 P-VI 40

1703283 Page 5
DEPARTMENT OF INFORMATION TECHNOLOGY,CEC LANDRAN

COURSE

Course_code Course_Name Teacher_name


C1 Visual Basic ABC
C2 Oracle &Dev DEF
C3 C++ KJP
C4 java kumar

Update Anomalies happen when the person charged with the task of keeping all the records current
and accurate, is asked, for example, to change an employee’s title due to a promotion. If the data is
stored redundantly in the same table, and the person misses any of them, then there will be multiple
titles associated with the employee. The end user has no way of knowing which is the correct title.

Deletion Anomalies happen when the deletion of unwanted information causes desired information
to be deleted as well. For example, if a single database record contains information about a
particular product along with information about a salesperson for the company and the salesperson
quits, then information about the product is deleted along with salesperson information.

5.Explain structure of XML document with suitable example.


ANS.-:The XML Recommendation states that an XML document has both logical and physical
structure. Physically, it is comprised of storage units called entities, each of which may refer to
other entities, similar to the way that include works in the C language. Logically, an XML
document consists of declarations, elements, comments, character references, and
processing instructions, collectively known as the markup.

An XML document consists of three parts, in the order given:

1. An XML declaration (which is technically optional, but recommended in most normal cases

2. A document type declaration that refers to a DTD (which is optional, but required if you want
validation)

3. A body or document instance

Data Model Terminology also used in XML-:

1703283 Page 6
DEPARTMENT OF INFORMATION TECHNOLOGY,CEC LANDRAN

Instance
The data model represented as a sequence.
Instance document
A document using and conforming to the same sequence/XML tree.
Sequence
An order collection of zero or more items. A sequence cannot be a member of
a sequence. A single item appearing individually is modeled as a sequence
containing one item.
Element
A node within the sequence that may contain
Node
Any item represented in the XML tree/sequence.
Root Node
The topmost element of the tree. All other elements and nodes must be
contained within the root node.
Item
A node or an atomic value.
Value space
The part of an item that contains data rather than additional elements.
Atomic type
A primitive simple type or a type derived by restriction from another atomic
type.
Atomic value
A value contained in the value space that is an atomic type.
QName
The qualified name of an element. It must conform to naming rules of XML
objects. (i.e. must start with a letter or underscore, case-sensitive, cannot start
with the letters xml(in any case), can contain letters, digits, hyphens,
underscores, and periods, cannot contain spaces.)

2. Solve the following on the given data base [using SQL]:


S (Sno, Sname, City, status)
P (Pno, Pname, color, weight)
SP(Sno, Pno , qty)

a) Get supplier number who supplies maximum quantities?

We first show a step-at-a-time solution

1703283 Page 7
DEPARTMENT OF INFORMATION TECHNOLOGY,CEC LANDRAN

TEMP1 [S#, SNAME, STATUS, CITY, P#, QTY]:= S JOIN SP;


TEMP2 [S#, SNAME, STATUS, CITY, P#, QTY]:=TEMP1 WHERE P#=’MAX’;
RESULT [SNAME] := TEMP2[SNAME;
Using a nested expression;
( ( S JOIN SP ) WHERE Pno = ‘MAX’ ) [ SNAME ]
The result of this expression has one attribute, with qua;ified name S SNAME.

b) Get total quantity supplied by S1?


Get supplier number for supplier who supply at least all those parts supplied by S1

SP [ Sno, Pno ] DIVIDE BY ( SP WHERE Sno = ‘S1’) [ Pno ]


Resultant attribute-name: SP.S#

1703283 Page 8

You might also like