Monday, April 6, 2015

M102: MongoDB for DBAs - Homework 3.3

Step 1:
Download the handout


Step 2:
import products.json using mongo import utility


mongoimport -d pcat -c products --drop products.json

Step 3:
now enter into mongo shell 
use pcat database using 
use pcat

Step 4:
add index on for field using 
db.products.ensureIndex({for:1});

Step 5:
now create and run the query you will  get answer as

q1) 4
q2) 4
q3) yes

No comments:

Post a Comment