Chapter 1. Introduction to MongoDB, key concepts
Concepts
What were the big differences in hardware over the last few decades that MongoDB attempted to address?
Scaling
Q: When scaling out horizontally (adding
more servers to contain your data), what are problems that arise as you
go from, say, 1 commodity server to a few dozen?
SQL and Complex Transactions
What causes significant problems for SQL when you attempt to scale horizontally (to multiple servers)?
Documents Overview
What are some advantages of representing our data using a JSON-like format?
JSON Types
How many data types are there in JSON?
- String
- Integer
- Boolean
- Null
- Array
- Object or documents (subdocuments)
JSON Syntax
What is the corresponding JSON for the following XML document?
<person> <name>John</name> <age>25</age> <address> <city>New York</city> <postalCode>10021</postalCode> </address> <phones> <phone type="home">212-555-1234</phone> <phone type="mobile">646-555-1234</phone> </phones> </person>
{"name":"John",
"age":25,
"address":{"city":"New York","postalCode":"10021"},
"phones":[
{"phone":"212-555-1234","type":"home"},
{"phone":"646-555-1234","type":"mobile"}
]
}
JSON Syntax 2
For the following XML, Is the corresponding JSON example legal json?
<things> <hat>one</hat> <coat>z</coat> <hat>two</hat> </things>
{ "hat" : "one", "coat" : "z", "hat" : "two" }
Binary JSON
Why do we represent our data as BSON rather than JSON in the system?
BSON and applications
For a typical client (a python client,
for example) that is receiving the results of a query in BSON, would we
convert from BSON to JSON to the client's native data structures (for
example, nested dictionaries and lists in Python), or would we convert
from BSON straight to those native data structures?
Dynamic Schema
True or False: MongoDB is schemaless because a schema isn't very important in MongoDB
What is the MongoDB shell?
Q: By default, which database does the mongo shell connect to?
Cursors Introduction
In order to query a collection in the mongo shell, we can type which of the following?
Query Language: Basic concepts
You have a collection where every 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. Furthermore, you want to eliminate all other fields from the query results. What query might you write?
Query Language: Projection
You want to query the “people”
collection, you want the results of the query to include only documents
where age is 50, and you want to look at all fields except “email”. What
query should you write?
Query Language: Advantages of a Dynamic Schema
If you want to add a new key: value pair to the documents in the “shapes” collection, what methods could you use?
Shell: Queries
We have sample documents in our products collection such as:
{ name: "AC1 Case Green", color: "green", price: 12.00, for: "ac1", type: ["accessory", "case"], available: true }How would we 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"?
db.products.find({"for":"ac9","type":"case"})
Sorting
If you want to run a query on the
collection, “books,” and sort ASCIIbetically by title on the query,
which of the following will work?
Query Language: Cursors
Recall the documents in the scores collection:
{ "_id" : ObjectId("50844162cb4cf4564b4694f8"), "student" : 0, "type" : "exam", "score" : 75 }Write a query that retrieves documents of type "exam", sorted by score in descending order, skipping the first 50 and showing only the next 20.
db.scores.find({"type":"exam"}).sort({"score":-1}).skip(50).limit(20)
Thank you for the fantastic service provided and helping me find a niche home at an affordable price. Appreciate your web designing team.
ResponderEliminarMongoDB Training in Chennai
azure devops online training
ResponderEliminarapp v online training
sccm online training
windows admin online training
mysql online training