Database Foundations - MongoDB
<field> : <value>
"name" : "Lashkmi"
Field
- a unique identifier for a datapoint.
Document
- a way to organize and store data as a set of field-value pairs.
Collection { "name" : "Gracie" "age" : 24 "height" : 56 }
- an organized store of documents in MongoDB, usually with common fields between documents. There can be many collections per database and many documents per collection.
Value
- data related to a given identifier.
BSON (Binary JSON)
A computer-readable format for data interchange that expands the JSON format to include additional data types including binary objects.
JSON (JavaScript Object Notation)
A data interchange language that is consistent and easy to read by both computers and humans.
What is an embedded document?
A value made up of multiple fields. Enclosed in curly brackets in JSON {}
Field names cannot contain null characters, dots (.), or dollar signs ($) A) BSON B) JSON
A) BSON
Why is MongoDB a NoSQL database? Check all answers that apply: A) Because it uses a structured way to store and access data B) Because it does not utilize tables, rows and columns to organize data
A) Because it uses a structured way to store and access data B) Because it does not utilize tables, rows and columns to organize data
Which is the correct operator to read? A) db.collection.find() B) db.collection.insertOne() C) db.collection.remove() D) db.collection.updateMany()
A) db.collection.find()
Which of the following documents is correct JSON? A. {"name" : "Devi", "age": 19, "major": "Computer Science"} B. {name : "Devi", age: 19, major: "Computer Science"} C. ["name" : "Devi", "age": 19, "major": "Computer Science"]
A. {"name" : "Devi", "age": 19, "major": "Computer Science"}
What is an array?
An array is a value made up of multiple elements of the same data type.
Which is the correct operator to create? A) db.collection.find() B) db.collection.insertOne() C) db.collection.remove() D) db.collection.updateMany()
B) db.collection.insertOne()
What type of database is MongoDB? (hint: a type of NoSQL database that stores data as individual documents.) A. Multimodel database B. Document database C. Table database D. Wide-column databse
B. Document database
Is this a BSON or JSON structure { _id: ObjectId("5099803df3f4948bd2f98391"), name: "New Project", version: 1, languages: ["JavaScript", "HTML", "CSS"], admin: {name: "Brad", password: "****"}, paths: {temp: "/tmp", project:"/opt/project", html: "/opt/project/html"} 8. }
BSON
_________________ is faster to parse and lighter to store than _____________
BSON is faster to parse and lighter to store than JSON.
Which is the correct operator to delete? A) db.collection.find() B) db.collection.insertOne() C) db.collection.remove() D) db.collection.updateOne()
C) db.collection.remove()
Use document references instead of embedded documents when A) embedding results in duplication of data B) representing many-to-many relationships C) model large hierarchical data sets. D) All of the above
D) All of the above
Which is the correct operator to update? A) db.collection.find() B) db.collection.insertOne() C) db.collection.remove() D) db.collection.updateMany()
D) db.collection.updateMany()
Maximum size of BSON document is 56MB TRUE/ FALSE
FALSE : maximum size is 16MB
Aggregation in MongoDB is ?
Grouping data by a common field and performing some type of operation based on the grouping
_____________ supports fewer data types than _________________
JSON supports fewer data types than BSON
Studio 3T lets you connect to which MongoDB environments?
MongoDB Server and MongoDB Atlas
MongoDB stores data in________________ , and you can then view it in ___________________
MongoDB stores data in BSON , and you can then view it in JSON
If you place a field in quotes, but precede it with a dollar sign (for example, $customer.name), the parser will return the value of the field. TRUE/ FALSE
TRUE
TRUE OR FALSE A database can contain multiple collections, but a collection cannot span multiple databases.
TRUE
Replica Set
a few connected machines that store the same data to ensure that if something happens to one of the machines the data will remain intact.
In a MongoDB Document what is the role of fields and values? Select all that apply: a. A field is a unique identifier for a specific datapoint. b. Values do not have to be attached to fields, and can be stand alone data points. c. Each field has a value associated with it.
a. A field is a unique identifier for a specific datapoint. c. Each field has a value associated with it.
You are inserting a document into a collection in a MongoDB database. One of the document's fields is an embedded document. Which data type does MongoDB assign to that field? a. Object b. Array c. ObjectId d. Document
a. Object
Which Studio 3T tool provides drag-and-drop capabilities for building queries? a. Visual Query Builder b. IntelliShell c. Connection Manager d. mongo shell
a. Visual Query Builder
An array is enclosed in ? a. [. ] b. (. ) c. {. } d. " "
a. [. ]
Each MongoDB document must include a field that serves as the primary key. What is the name of this field? a. _id b. _pk c. ObjectId d. Identifier
a. _id
____________________ can import data from JSON, and other supported non BSON formats. a. mongoimport b. mongodump c. mongoexport d. mongorestore
a. mongoimport
an instance is the ______________ ____________ and collection of processes running on the server.
allocated memory and collection of processes running on the server
An array is assigned the ____________ data type
array data type
When does MongoDB create the files associated with a database? a. When you create the database b. When you add your first collection to the database c. When you add your first document to a collection d. When you create an index on a collection
b. When you add your first collection to the database
After you install Studio 3T, you create a connection to the local MongoDB instance that uses the default listening port. Which connection member value does Studio 3T provide for the local instance? a. localhost:1433 b. localhost:27017 c. :445 d. :187978
b. localhost:27017
__________________ exports data in its raw BSON form. a. mongoimport b. mongodump c. mogoexport d. mongorestore
b. mongodump
Which MongoDB method can you use to load and run a script file? a. find b. use c. load d. getDB
c. load
____________________ does work with JSON, but it would export it, thus making a copy of the data outside of the Atlas cluster, rather than adding a collection to the Atlas cluster. a. mongoimport b. mongodump c. mongoexport d. mongorestore
c. mongoexport
A collection can contain how many documents? a. one to many b. only one c. zero to many d. many to many
c. zero to many
An embedded document is enclosed in? a. [. ] b. (. ) c. {. } d. " "
c. {. }
a database is a _________________ of files that reside on the ________________.
collection of files that reside on the server.
SQL is to tables as MongoDB is to ______________
collections
The MongoDB data structure is organized into an object hierarchy. What is the order of that hierarchy from top to bottom? a. Collection, database, document b. Collection, document, database c. Database, document, collection d. Database, collection, document
d. Database, collection, document
______________ imports data from a mongodump created BSON format. a. mongoimport b. mongodump c. mongoexport d. mongorestore
d. mongorestore
SQL is to data type as MongoDB is to ______________
data type
Translate this SQL command to Mongo SELECT COUNT(*) FROM people
db.people.count() OR db.people.find().count()
Translate this SQL command to Mongo SELECT COUNT(user_id) FROM people
db.people.count({ user_id : {$exists : true } } )
SQL is to row as MongoDB is to ______________
documents (BSON)
SQL is to columns as MongoDB is to ______________
fileds
Cluster
group of servers that store your data.
NoSQL databases
is a "non-relational" database that provides a mechanism for storage and retrieval of data that is modeled in means other than the tabular relations used in relational databases
Command-line tool:
is a means of interacting with a computer program where the user (or client) issues commands to the program in the form of successive lines of text
An embedded document is assigned the ____________ data type
object data type
What is namespace ?
the name for a collection or index in MongoDB.
true or false The document, which is comprised of field/value pairs, is at the heart of the MongoDB data structure.
true