Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

MongoDB Laboratory This laboratory is dedicated to MongoDB, a document data store that belongs to the NoSQL family. The main goal for this laboratory is

MongoDB Laboratory
This laboratory is dedicated to MongoDB, a document data store that belongs to the NoSQL family.
The main goal for this laboratory is to gain familiarity with a typical MongoDB use case. The interested student can understand the details of MongoDB by playing with the command line interface that interacts with the MongDB server. On the official website (http://www.mongodb.org/) it is possible to find the list of commands supported by MongDB, and additional useful documentation.
Installing and running the MongoDB server
MongoDB can be downloaded from the following webpage: https://www.mongodb.org/downloads
Put the downloaded file wherever you prefer, open a terminal, go to the directory where you put the downloaded file, then type the following commands
tar -xzf mongodb-linux-x86_64-2.6.5.tgz cd mongodb-linux-x86_64-2.6.5
sudo mkdir p /data/db
sudo ./bin/mongod
The last command will launch the server, and MongoDB is ready to accept connection on port 27017.
Interacting with the MongoDB server
In order to interact with the MongoDB server, a client is necessary. The client will connect to the server on port 27017 and it will send the commands through the connection. In this lab, we will use the Java client; these are the steps to follow for using such a client:
Download the jar of the Jedis client: http://central.maven.org/maven2/org/mongodb/mongo-java- driver/2.12.4/mongo-java-driver-2.12.4.jar
o alternatively, check this page http://docs.mongodb.org/ecosystem/drivers/java/
Put the jar in the same directory of your Java program;
In your Java program, import the Jedis class:
import com.mongodb.*;
In your Java program, use the Jedis client, e.g.:
MongoClient mongo = new MongoClient("localhost", 27017);
Compile your Java program:
javac -cp mongo-java-driver-2.12.4.jar myProgram.java
Run your Java program (that includes the Redis client):
java -cp '.: mongo-java-driver-2.12.4.jar' myProgram
The student can use as a starting point the file ecommerce_mongodb.java provided on the course web page. For additional information, check this web page: http://docs.mongodb.org/ecosystem/tutorial/getting-started-with-java-driver/
image text in transcribed
please solve them .
1.1 Exercise I Problem statement: Find Albums by Genre and Sort by Year Produced. Hint: To support this query, create a compound index on all the properties used in the filter and in the sort. 1.2 Exercise 2 Problem statement: Find Products Sorted by Percentage Discount Descending. While most searches will be for a particular type of product (e.g album, movie, etc..) in some situations you may want to return all products in a certain price range, or discount percentage. Hint: To support this type of query, you will want to create an index on the pricing.pct_savings field 1.3 Exercise 3 Problem statement: Find Movies Based on Starring Actor. Hint: To support this query, you may want to create indexes

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions