LAB MANUAL Advanced ADBMS
LAB MANUAL Advanced ADBMS
LAB MANUAL Advanced ADBMS
TECHNOLOGY
LAB MANUAL
CLASS:TE(IT)
TERM:I
SUBJECT: LABORATORY PRACTICE-I (ADBMS)
COURSE: 2019 PATTERN
ACADEMIC YEAR: 2022-23
3 Assignment No:-1
Group-B)Updating document 18 TO 19
4 Assignment No:-2 23 TO 26
27
5 Assignment No:-3
Case Study: Design conceptual model using Star and
Snowflake schema for any one database.
28
6 Assignment No:-4
Mini Project
To equip students with core and state of the art Information Technologies.
Mission
Imparting knowledge of Information Technology and teaching its application
through innovativepractices and to instil high morale, ethics, lifelong learning skills,
concern for the society and environment.
1. Examiners will assess the student based on performance of students considering the
parameters such as timely conduction of practical assignment, methodology adopted for
implementation of practical assignment, timely submission of assignment in the form of
handwritten write-up alongwith results of implemented assignment, attendance etc.
2. Appropriate knowledge of usage of software and hardware related to respective laboratory
shouldbe checked by the concerned faculty member.
3. As a conscious effort and little contribution towards Green IT and environment awareness,
attachingprinted papers of the program in journal may be avoided. There must be hand-written
write-ups for every assignment in the journal. The DVD/CD containing student’s programs
should be attached to the journal by every student and same to be maintained by
department/lab In- charge is highly encouraged. For reference one or two journals may be
maintained with program prints at Laboratory.
Reference Books:
1. Silberschatz A., Korth H., Sudarshan S., "Database System Concepts", 6thEdition, McGraw
HillPublishers, ISBN 0-07-120413-X.
2. Kristina Chodorow, MongoDB The definitive guide, O’Reilly Publications, ISBN:978-93-5110-
269-4,2nd Edition.
3. Jiawei Han, Micheline Kamber, Jian Pei “Data Mining: concepts and techniques”, 2nd
Edition,Publisher: Elsevier/Morgan Kaufmann.
4. http://nosql-database.org/.
Reference Books:
5. Silberschatz A., Korth H., Sudarshan S., "Database System Concepts", 6thEdition, McGraw
HillPublishers, ISBN 0-07-120413-X.
6. Kristina Chodorow, MongoDB The definitive guide, O’Reilly Publications, ISBN:978-93-5110-
269-4,2nd Edition.
7. Jiawei Han, Micheline Kamber, Jian Pei “Data Mining: concepts and techniques”, 2nd
Edition,Publisher: Elsevier/Morgan Kaufmann.
8. http://nosql-database.org/.
1 Assignment No:-1
2 Assignment No:-2
Implement Map-reduce and aggregation, indexing with suitable example inMongoDB.
3 Assignment No:-3
Case Study: Design conceptual model using Star and Snowflake schema for any one database.
4 Assignment No:-4
Mini Project
Title:- Create a database with suitable example using MongoDB and implement
RDBMS MongoDB
Database Database
Table Collection
Tuple/Row Document
column Field
Mysqld/Oracle mongod
mysql/sqlplus mongo
No complex joins.
MongoDB use DATABASE_NAME is used to create database. The command will create
anew database if it doesn't exist, otherwise it will return the existing database..
Syntax
use DATABASE_NAME
>db
mydb
If you want to check your databases list, use the command show dbs.
>show dbs
local 0.78125GB
test 0.23012GB
In MongoDB default database is test. If you didn't create any database, then
collectionswill be stored in test database.
Syntax
db.dropDatabase()
This will delete the selected database. If you have not selected any database, then it
willdelete default 'test' database.
Eg. If you want to delete new database <mydb>, then dropDatabase() command would
beas follows:
>use mydb
switched to db mydb
>db.dropDatabase()
>{ "dropped" : "mydb", "ok" : 1 }
>
Syntax
db.createCollection(name, options)
Examples
>use test
switched to db test
>db.createCollection("mycollection")
{ "ok" : 1 }
>
You can check the created collection by using the command show collections.
>show collections
mycollection
system.indexes
>db.tutorialspoint.insert({"name" : "tutorialspoint"})
>show collections
mycol
mycollection
system.indexes
tutorialspoint
>
db.COLLECTION_NAME.drop()
Example
>db.mycollection.drop()
true
>
To insert document
To insert data into MongoDB collection, you need to use MongoDB's insert()
or save()method.
Syntax
>db.COLLECTION_NAME.insert(document)
Example:-
>db.mycol.insert({
})
Here mycol is our collection name, as created in the previous. If the collection doesn't
exist in the database, then MongoDB will create this collection and then insert a
document into it.
In the inserted document, if we don't specify the _id parameter, then MongoDB assigns
aunique ObjectId for this document.
To insert multiple documents in a single query, you can pass an array of documents
ininsert() command.
Example:
>db.post.insert([
},
])
To insert the document you can use db.post.save(document) also. If you don't specify
_id in the document then save() method will work same as insert() method. If the save()
method.
The save() method replaces the existing document with the new document passed in thesave() method.
Syntax
>db.COLLECTION_NAME.save({_id:ObjectId(),NEW_DATA})
>db.mycol.save(
{
"_id" : ObjectId(5983548781331adf45ec7), "title":"Tutorials Point New
Topic",
"by":"Tutorials Point"
}
)
>db.mycol.find()
{ "_id" : ObjectId(5983548781331adf45ec5), "title":"Tutorials Point New Topic",
"by":"Tutorials Point"}
{ "_id" : ObjectId(5983548781331adf45ec6), "title":"NoSQL Overview"}
{ "_id" : ObjectId(5983548781331adf45ec7), "title":"Tutorials Point Overview"}
>
Conclusion:Thus ,we have studied about how to create and save document in
Mongodb.
Theory:-
MongoDB's update() and save() methods are used to update document into a collection.
The update() method updates the values in the existing document while the save()
methodreplaces the existing document with the document passed in save() method.
>db.COLLECTION_NAME.update(SELECTIOIN_CRITERIA, UPDATED_DATA)
Example
Following example will set the new title 'New MongoDB Tutorial' of the documents
whosetitle is 'MongoDB Overview'.
>db.mycol.update({'title':'MongoDB Overview'},
{$set:{'title':'New MongoDB Tutorial'}},{multi:true})
c. $ where queries
Theory:-
Syntax:
db.collection.findOne(query, projection)
show dbs;
Select a particular database to access, e.g. mydb . This will create mydb if it does not
already exist:
use mydb;
2. Show all collections in the database (be sure to select one first, see above):
show collections;
> db
mydb
db.dropDatabase()
>db.COLLECTION_NAME.update(SELECTIOIN_CRITERIA, UPDATED_DATA)
>db.mycol.update({'title':'MongoDB Overview'},{$set:{'title':'New MongoDB
Tutorial'}})
db.test.find({})
10. To skip first 3 documents:
db.test.find({}).skip(3)
11. To sort descending by the field name:
db.test.find({}).count()
Theory:-
1. Map-Reduce
In very simple terms, the mapReduce command takes 2 primary inputs, the mapper function and the
reducer function. A Mapper will start off by reading a collection of data and building a Map with
only the required fields we wish to process and group them into one array based on the key.
And then this key value pair is fed into a Reducer, which will process the values. Map/Reduce is a
framework which allows to parallelize the processing of large and very large datasets across many
physical or virtual servers. A typical Map Reduce program consists of two phases .
Map: – It is a JavaScript function. It is used to map a value with a key and produces a key-value
pair.
Reduce: – It is a JavaScript function. It is used to reduce or group together all the documents
whichhave the same key.
Advantages
Scalable (due to simple design) Runs
on cheap commodity hardware
Procedural control i.e. we can control of the execution of every step
Disadvantages
1. It is not flexible i.e. the MapReduce framework is rigid.
A lot of manual coding is required, even for common operations such as join, filter, projection,
aggregates, sorting, distinct...
2. Semantics are hidden inside the map and reduce functions, so it is difficult to maintain,
extendand optimize them
Application Of MapReduce
Entertainment: To discover the most popular movies, based on what you like and what you
watched in this case Hadoop MapReduce help you out. It mainly focuses on their logs and clicks.
E-commerce: Numerous E-commerce suppliers, like Amazon, Walmart, and eBay, utilize the
MapReduce programming model to distinguish most loved items dependent on clients’ inclinations
or purchasing behavior.
It incorporates making item proposal Mechanisms for E-commerce inventories, examining website
records, buy history, user interaction logs, etc.
Data Warehouse: We can utilize MapReduce to analyze large data volumes in data warehouses
while implementing specific business logic for data insights.
Fraud Detection: Hadoop and MapReduce are utilized in monetary enterprises, including
organizations like banks, insurance providers, installment areas for misrepresentation recognition,
pattern distinguishing proof, or business metrics through transaction analysis.
2 :- Indexing
•Indexes support the efficient execution of queries in MongoDB. Indexes support the efficient
resolution of queries. Without indexes, MongoDB must scan every document of a collection to
select those documents that match the query statement. This scan is highly inefficient and
require MongoDB to process a large volume of data.
Indexes are special data structures, that store a small portion of the data set in an easy-to-
traverse form. The index stores the value of a specific field or set of fields, ordered by the valueof
the field as specified in the index.
Syntax
The basic syntax of createIndex() method is as follows().
Index Display
db.collection.getIndexes()
Index Drop
db.collection.dropIndex()
3:- Aggregation
Aggregation operations group values from multiple documents together, and can perform a
variety of operations on the grouped data
For aggregation in mongodb use aggregate() method.
Expression Description
$sum Sums up the defined value from all documents in the collection.
$avg Calculates the average of all given values from all documents in the collection.
$min Gets the minimum of the corresponding values from all documents in the
collection.
$max Gets the maximum of the corresponding values from all documents in
thecollection.
$first Gets the first document from the source documents according to the grouping.
$last Gets the last document from the source documents according
db.student.aggregate ([{$group :
{_id : "$subject",
marks : {$min : "$marks"}}}]);
MAX()
db.student.aggregate ([{$group :
{_id : "$subject",
marks : {$max : "$marks"}}}]);
AVG()
db.student.aggregate ([{$group :
{_id : "$subject",
marks : {$avg : "$marks"}}}]);
FIRST()
db.student.aggregate ([{$group :
{_id : "$subject",
marks : {$first : "$marks"}}}]);
LAST()
db.student.aggregate ([{$group :
{_id : "$subject",
marks : {$last : "$marks"}}}]);
conclusion:Thus ,we have studied about how to use map-reduce, aggregation and indexing in
Mongodb.
Pre-requisite: Build the mini project based on the requirement document and design
prepared as apart of Database Management Lab in second year.
1. Form teams of around 3 to 4 people.
2. Develop the application:Build a suitable GUI by using forms and placing the controls on
it for any application. Proper data entryvalidations are expected.
Add the database connection with front end. Implement the basic CRUD operations.
Prepare and submit report to include: Title of the Project, Abstract, List the hardware and
software requirements at the backend and at the front end, Source Code , Graphical User
Interface, Conclusion.