Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NoSQL DataBase Please I need solutions for Exercise 1,2,3 MongoDB Laboratory This laboratory is dedicated to MongoDB, a document data store that belongs to the

NoSQL DataBase
Please I need solutions for Exercise 1,2,3 image text in transcribed
image text in transcribed
image text in transcribed
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 (hetp i/www mongodb orge 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: hatps:/www. mongodb.org/dowaloads Put the downloaded file wherever you prefer, open a terminal, go to the directory where yoo pot the downloaded file. then type the following commands tar xaf mongodb-1inux-x86 642,65,tgz cd mongodb-1inux-x86 642,6,5 sudo m kdir p/data/db sudo +/bin/ mongod The last command will launch the server, and MongoDB is ready to accept coanection oa 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: hatpilleentral maven org/mayen2lorg/mongodbimongojayaz driver/2.12.4/mongo-javazdriver-2,12.4, jar a alternatively, check this page bitgdildocs mongodb.org/ecosystem/driven/jasal - Pul the jar in the same directory of yoar Java program; - Ia your Java program, import the Jedis class: import com,mongodl. **; - In your Java program, use the Jedis client, ega Mongoclient mongo = new Mongoclient ( "1ocalhost", 27017); - Compile your Java program: javae -ep mongo-java-tiriver-2.12.4. jar myPrograan.java - Run your Java program (that includes the Redis client): java -ep ".t mongo-java-driver-2.12.4.jar' myprogram The student can uve as a starting point the file "ecomamerce_ mongodb.java" provided on the coarse web page. For additional information, check this web page: http: Ndocs mongodb ogglecosyatem/tutoriallgetting-atarted-with-java-Hriver! 1 Exercise - Product Catalog We will see the basic patterns and principles for designing at E-Commerce product catalog system using MongoDB as a storage engine. Product catalogs must have the capacity to store many differed types of objects with different sets of attributes. These kinds of data collections are quite compatible with MongoDB's data model: we will wse a single MongoDB collection to store all the product data. MongoDB's dynamic schema means that each document need not conform to the same schema. As a result, the document for each product only needs to contain attributes relevant to that product. To this aim, at the beginning of each document, the schema must contain general product information, to facilitate searches of the entire catalog. Then, a details sab-document that contains fields that vary between prodoct types. Consider the following example document for an album product. A movie item would have the same fields for general product information, shipping, and pricing, but have different details sub-document. Consider the following: For most deployments the primary use of the product catalog is to perform search operations. These exercises provide an overview of various types of queries that may be useful for supporting an e-commerce site. The exercises are inspired by the following example: hrp:ildocsmongodborglesosystem/use-caseviproduct-catalog/ 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 to Expert-Tailored 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

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

b. Determine the number of dependent variables, p.

Answered: 1 week ago