Labels

Sunday, 10 January 2016

MongoDB : Interview question and answers

What were the big differences in hardware over the last few decades that MongoDB attempted to address ?

Parallelism of Cores and Parallelism of Servers.

When Scaling out horizantolly i.e adding more servers to contain your data what are the problem we will face ?

The servers must communicate with one another eating up network band width.

The need of redundancy increases as the likelihood of some failures in the system per unit of time increases.

What causes significant problems for SQL when you attempt to scale horizontally (to multiple servers) ?

We will face significant problems with Joins and Transactions

What are the advantages of representing our data using a JSON like format ?

JSON is optimized for use with Java Script

JSON Syntax is similar to that of data structures used in many programming languages and is there of familiar to developers

JSON presents a flexible and concise framework for specifying queries as well as storing Records.

How Many data types are there in JSON ?

JSON supports 6 types of data types that are Strings , Numbers ,boolean (T/F), Null , Arrays and Objects / Documents .

Why do we need to represent our data in BSON rather than JSON syntax in the system ?

Fast machine scanability and Stronger typing than JSON.

By Default which database does the Mongo shell connect to?

Test

The mongoimport utility can import what types of data ?

mongoimport utility supports JSON , CSV and TSV files

In order to query a collection in the mongo shell what do we need to use ?

db.collection.find()

You have a collection where ever document has the same fields and you want to look at the value of the "_id","name" and "email" fields in order to see their format . Further more , you want to eliminate all other fields from the query results what query you might write ?

db.collection.find({},{name:1,email:1})

You want to query the "people" collection and you want the results of the query to include only documents where age is 50 and you want to look at  all the fields except "email" what query should you write ?

db.people.find({age:50},{email:0})


If you want to add a new key : value pair to the documents in the "shapes" collection what methods could you use ?

db.shapes.update()

db.shapes.save()

Assume we have some sample collection in our products collection such as 
{name:"AC1 Case Green",color : "green" ,price:12.00,for:"ac1",type:["accessory case"],available:true }

How we would query in the shell for all products that are cases for an ac9 phone ? That is , where type contains the value "case" and for equals "ac9"?

Please use filed names in the order they appear in the question and use double quotes around values ?

db.products.find({"type":"case", "for":"ac9"})

If you want to run a query on the collection "books" and sort ASCII betically by title on the query then how you will write ?

db.books.find().sort({title:1})

Recall the documents in the score collection 
({"student":0,"type":"exam","score":75}
write a query that retrieves document type "exam" , sorted by score in descending order and skip the first 50 and showing only the next 20.

db.scores.find({type:"exam"}).sort({score:-1}).skip(50).limit(20)




1 comment:

  1. Step by step instructions to Solve MongoDB Error Import CSV File in Database through MongoDB Technical Support
    At whatever point you import the CSV record in MongoDB then you will get a mistake message which indicates "Linguistic structure Error". Extraordinary compared to other approaches to tackle this issue is endeavoring to run it in OS Shell not in Mongo Shell. So quickly you need to leave Mongo shell and keep running in OS shell. Be that as it May, if again can't import CSV document at that point rapidly connect with MongoDB Customer Support USA or MongoDB Online Support. Aside from this issue in the event that you have any inquiry or question then you can get our Support for MongoDB Database Software.
    For More Info: https://cognegicsystems.com/
    Contact Number: 1-800-450-8670
    Email Address- info@cognegicsystems.com
    Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

    ReplyDelete