0% found this document useful (0 votes)
23 views10 pages

23 Win

The document provides a series of MongoDB queries for managing an inventory collection, explanations of structured types and inheritance in SQL, and XQuery examples for XML data. It also discusses fragmentation techniques on a student table, compares data mining and data warehousing, and outlines the MapReduce architecture and its phases. Each section includes code snippets and examples to illustrate the concepts.

Uploaded by

humera.bagwan01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views10 pages

23 Win

The document provides a series of MongoDB queries for managing an inventory collection, explanations of structured types and inheritance in SQL, and XQuery examples for XML data. It also discusses fragmentation techniques on a student table, compares data mining and data warehousing, and outlines the MapReduce architecture and its phases. Each section includes code snippets and examples to illustrate the concepts.

Uploaded by

humera.bagwan01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

2023 winnter adm

Answer for Question 5

(a) MongoDB Queries on Collection: Inventory


1. To display all documents in the collection:
javascript
Copy code
db.Inventory.find({})

2. To display all documents where the status equals


"D":
javascript
Copy code
db.Inventory.find({ status: "D" })

3. To display all documents where the status equals


either "A" or "D":
javascript
Copy code
db.Inventory.find({ status: { $in:
["A", "D"] } })

4. To display all documents where the status equals "A"


and qty is less than 30:
javascript
Copy code
db.Inventory.find({ status: "A", qty:
{ $lt: 30 } })

5. To display all documents where the status equals "A"


or qty is greater than 30:

1 | Page
2023 winnter adm

javascript
Copy code
db.Inventory.find({ $or: [{ status:
"A" }, { qty: { $gt: 30 } }] })

6. To display all documents where the status equals "A"


and either qty is less than 30 or item starts with
character "P":
javascript
Copy code
db.Inventory.find({
status: "A",
$or: [{ qty: { $lt: 30 } }, { item:
{ $regex: /^P/ } }]
})

(b) Explanation of Structured Types and Inheritance in


SQL
 Structured Types:
Structured types in SQL allow users to define custom
data types that group together multiple attributes.
Example:
sql
Copy code
CREATE TYPE Address AS (
street VARCHAR(50),
city VARCHAR(30),
zipcode INT
);

 Inheritance:
Inheritance in SQL allows tables to inherit properties
2 | Page
2023 winnter adm

from other tables.


Example:
sql
Copy code
CREATE TABLE Employee (
emp_id INT PRIMARY KEY,
name VARCHAR(50)
);

CREATE TABLE Manager (


dept_id INT,
FOREIGN KEY (emp_id) REFERENCES
Employee(emp_id)
) INHERITS (Employee);

(c) XQuery for Books XML


XML Code (books.xml):
xml
Copy code
<bookstore>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J.K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>

3 | Page
2023 winnter adm

</book>
</bookstore>

1. Select all the title elements in the "book.xml" file:


xquery
Copy code
for $title in //title
return $title

2. Select all the book elements under the bookstore


element that have a price element with a value less
than 30:
xquery
Copy code
for $book in //book
where $book/price < 30
return $book

Answer for Question 6


(a) Fragmentation on the Student Table
1. Horizontal Fragmentation (with key column "City"):
Horizontal fragmentation divides the table into smaller
subsets of rows based on the value of a specific column
(e.g., City).
o Fragment 1 (City = Kolkata):

Last
Enrollm First Contact Cour
Na City
ent Id Name No. se Id
me
1011 Dinanj Gupt Kolka 9272567 C345

4 | Page
2023 winnter adm

Last
Enrollm First Contact Cour
Na City
ent Id Name No. se Id
me
an a ta 819
Meht Kolka 9801273
1015 Juhi C689
a ta 883

o Fragment 2 (City = Hooghly):


Enroll First Cou
Last Contac
ment Nam City rse
Name t No.
Id e Id
Shey Hoog 981678 C68
1012 Gupta
ashi hly 2341 9
Mukher Hoog 989123 C34
1014 Ishan
jee hly 2134 5

o Fragment 3 (City = Malda):


Last
Enrollm First Contact Cour
Na City
ent Id Name No. se Id
me
Shubh Mald 8967095
1016 Roy C100
am a 626
Sinh Mald 9834582
1017 Rahul C689
a a 313

2. Vertical Fragmentation (with key column


"Enrollment Id"):

5 | Page
2023 winnter adm

Vertical fragmentation divides the table into smaller


subsets of columns, retaining a common key column
(Enrollment Id).
o Fragment 1 (Basic Details):

Enrollmen First Last


City
t Id Name Name
Kolkat
1011 Dinanjan Gupta
a
Hoogh
1012 Sheyashi Gupta
ly
Hoogh
1013 Milan Gupta
ly
Mukherj Hoogh
1014 Ishan
ee ly
Kolkat
1015 Juhi Mehta
a
Shubha
1016 Roy Malda
m
1017 Rahul Sinha Malda

o Fragment 2 (Contact and Course Details):


Enrollmen Contact Course
t Id No. Id
92725678
1011 C345
19
1012 98167823 C689

6 | Page
2023 winnter adm

Enrollmen Contact Course


t Id No. Id
41
78612348
1013 C709
79
98912321
1014 C345
34
98012738
1015 C689
83
89670956
1016 C100
26
98345823
1017 C689
13

(b) Comparison Between Data Mining and Data


Warehousing (Any Six Points)
Data
Aspect Data Mining
Warehousing
Process of Centralized
Definitio extracting patterns repository for
n and insights from storing historical
data. data.
To analyze data To consolidate
Purpose and predict future data from multiple
trends. sources.
Data Focuses on specific Provides a global
7 | Page
2023 winnter adm

Data
Aspect Data Mining
Warehousing
view of
datasets for
Scope organizational
analysis.
data.
Clustering,
Techniqu ETL (Extract,
Classification,
es Used Transform, Load).
Association.
Weka, RapidMiner, Oracle, SQL
Tools
SAS. Server, Teradata.
Prepares data for
Generates
Outcome analysis and
actionable insights.
reporting.

(c) Map Reduce Architecture and Explanation


Input Data:
vbnet
Copy code
Welcome to Hadoop class
Hadoop is good
Hadoop is bad

1. MapReduce Architecture:
mathematica
Copy code
Input Data

Split Input

8 | Page
2023 winnter adm


Mapping Phase

Shuffling and Sorting

Reducing Phase

Final Output

2. Phases of MapReduce:
o Input Splitting:

The input data is divided into smaller chunks.


Example:
kotlin
Copy code
Split 1: Welcome to Hadoop class
Split 2: Hadoop is good
Split 3: Hadoop is bad

o Mapping Phase:
Each split is processed by the mapper to generate
intermediate key-value pairs.
Example:
scss
Copy code
(Hadoop, 1), (Welcome, 1), (to, 1),
(class, 1), (Hadoop, 1), (is, 1),
(good, 1), (Hadoop, 1), (is, 1),
(bad, 1)

o Shuffling and Sorting:


The intermediate key-value pairs are grouped and

9 | Page
2023 winnter adm

sorted by key.
Example:
css
Copy code
(Hadoop, [1, 1, 1]), (Welcome,
[1]), (to, [1]), (class, [1]), (is,
[1, 1]), (good, [1]), (bad, [1])

o Reducing Phase:
The reducer processes the grouped pairs to produce
the final output.
Example:
scss
Copy code
(Hadoop, 3), (Welcome, 1), (to, 1),
(class, 1), (is, 2), (good, 1),
(bad, 1)

3. Final Output:
makefile
Copy code
Hadoop: 3
Welcome: 1
to: 1
class: 1
is: 2
good: 1
bad: 1

10 | P a g e

You might also like