MONGODB COMPLETE SET OF CURRENT EXAM QUESTIONS AND
CORRECT ANSWERS
What is MongoDB? - ANSWER A non-relational, schemaless store of JSON
documents
Schemaless - ANSWER Two documents do not have to have the same schema
Which features did MongoDB omit to retain scalability (2)? - ANSWER (1)
Joins, (2) Transactions across multiple collections
What are the two data structure that live within JSON? - ANSWER (1) Arrays
- lists of things, (2) Dictionaries - associative maps
dynamic typing - ANSWER A programming language is said to be
dynamically typed, or just 'dynamic', when the majority of its type checking is
performed at run-time as opposed to at compile-time. In dynamic typing, types
are associated with values not variables.
static typing - ANSWER A programming language is said to use static typing
when type checking is performed during compile-time as opposed to run-time.
In static typing, types are associated with variables not values.
What's the primary difference between Python dicts and JSON dictionaries? -
ANSWER JSON dictionaries preserve the order of the key-value pairs whereas
Python dicts are orderless.
Python exception handling - ANSWER import sys. try: "code" , except: print
"exception ", sys.exc_info()[0]
CRUD - ANSWER "Create Read Update Delete" --> "Insert Find Update
Remove". Things that can be performed on records.
Does MongoDB have its own query language? - ANSWER No, Mongo's
CRUD operations exist as methods/functions in programming language APIs,
not as separate language
,What is the interactive language for the MongoDB shell? - ANSWER
JavaScript - can type it right in the shell!
BSON - ANSWER Binary representation of JSON. Supports basic data types
that Mongo contains.
How does MongoDB's < / > query operators work for strings? - ANSWER
Retrieves based on Ascii character order. Case sensitive. Ex:
db.uses.find({name:{$gte :"F",$lte:"Q"}}) <> db.uses.find({name:{$gte
:"f",$lte:"Q"}})
What does $type do while using the "find" method - ANSWER Returns values
from the specified field that match the character type. $type values are numeric
and correspond to the BSON type as specified in the BSON documentation.
What's the single most important factor in designing your application schema
with MongoDB? - ANSWER Matching the data access patterns of your
application
Rich documents - ANSWER More than just tabular data. Includes arrays, key-
values, etc. Allows for "pre-joins" or embedded data
Does MongoDB have constraints? (ex: FK constraints) - ANSWER Nope.
Less of an issue b/c of embbedding
Atomic operations - ANSWER An operation during which a processor can
simultaneously read a location and write it in the same bus operation. This
prevents any other processor or I/O device from writing or reading memory
until the operation is complete.
What are the goals of normalization in relational databases? (3) - ANSWER
(1) free the database of modification anomalies, (2) minimize redesign when
extending, and (3) avoid bias toward any particular access pattern
Access pattern - ANSWER An access pattern is a specification of an access
mode for every attribute of a relation schema, i.e., it is an indication of which
attributes are used as input and which ones are used as output.
What can you do to make your MongoDB 'schema' more effective. - ANSWER
Embed and pre-join anywhere you can.
ACID - ANSWER "Atomicity, Consistency, Isolation, Durability". A set of
properties that guarantee that database transactions are processed reliably.
, database transaction - ANSWER A transaction comprises of a unit of work
performed within a DBMS against a database and treated in a coherent and
reliable way independent of other transactions.
atomicity (ACID) - ANSWER When a series of database operations either all
occur or nothing occurs. Prevents updates to the database occurring only
partially.
consistency (ACID) - ANSWER Guarantee that database constraints are not
violated, particularly once a transaction commits.
isolation (ACID) - ANSWER How transaction integrity is visible to other
users and systems.
durability (ACID) - ANSWER Guarantee that transactions that have
committed will survive permanently.
What are two reasons you might want to keep two documents that are related to
each other one-to-one in separate collections? - ANSWER 1) to reduce the
working set size of your applications, (2) because the combined size of the
documents would be larger than 16MB.
When is it recommended to represent a one to many relationship in multiple
collections? - ANSWER When the "many" is large.
What is the biggest advantage of embedding? - ANSWER Improved read
performance - only one round trip needed to the DB.
GRIDFS - ANSWER Will break-up large file (>64 MB) into chunks and store
chunks in a collection AND will store meta-data about the chunks in another
collection.
What are the costs of indexes? - ANSWER They take up space on disk and
they need to be updated when new records are added.
Which optimization will typically have the greatest impact on the performance
of a database? - ANSWER Adding appropriate indexes on large collections so
that only a small percentage of queries need to scan the collection.
Are you allowed to build MultiKey Indexes when both keys are array? -
ANSWER No, cartesian match too big. However, you can build one if one is an
index and the other isn't.
CORRECT ANSWERS
What is MongoDB? - ANSWER A non-relational, schemaless store of JSON
documents
Schemaless - ANSWER Two documents do not have to have the same schema
Which features did MongoDB omit to retain scalability (2)? - ANSWER (1)
Joins, (2) Transactions across multiple collections
What are the two data structure that live within JSON? - ANSWER (1) Arrays
- lists of things, (2) Dictionaries - associative maps
dynamic typing - ANSWER A programming language is said to be
dynamically typed, or just 'dynamic', when the majority of its type checking is
performed at run-time as opposed to at compile-time. In dynamic typing, types
are associated with values not variables.
static typing - ANSWER A programming language is said to use static typing
when type checking is performed during compile-time as opposed to run-time.
In static typing, types are associated with variables not values.
What's the primary difference between Python dicts and JSON dictionaries? -
ANSWER JSON dictionaries preserve the order of the key-value pairs whereas
Python dicts are orderless.
Python exception handling - ANSWER import sys. try: "code" , except: print
"exception ", sys.exc_info()[0]
CRUD - ANSWER "Create Read Update Delete" --> "Insert Find Update
Remove". Things that can be performed on records.
Does MongoDB have its own query language? - ANSWER No, Mongo's
CRUD operations exist as methods/functions in programming language APIs,
not as separate language
,What is the interactive language for the MongoDB shell? - ANSWER
JavaScript - can type it right in the shell!
BSON - ANSWER Binary representation of JSON. Supports basic data types
that Mongo contains.
How does MongoDB's < / > query operators work for strings? - ANSWER
Retrieves based on Ascii character order. Case sensitive. Ex:
db.uses.find({name:{$gte :"F",$lte:"Q"}}) <> db.uses.find({name:{$gte
:"f",$lte:"Q"}})
What does $type do while using the "find" method - ANSWER Returns values
from the specified field that match the character type. $type values are numeric
and correspond to the BSON type as specified in the BSON documentation.
What's the single most important factor in designing your application schema
with MongoDB? - ANSWER Matching the data access patterns of your
application
Rich documents - ANSWER More than just tabular data. Includes arrays, key-
values, etc. Allows for "pre-joins" or embedded data
Does MongoDB have constraints? (ex: FK constraints) - ANSWER Nope.
Less of an issue b/c of embbedding
Atomic operations - ANSWER An operation during which a processor can
simultaneously read a location and write it in the same bus operation. This
prevents any other processor or I/O device from writing or reading memory
until the operation is complete.
What are the goals of normalization in relational databases? (3) - ANSWER
(1) free the database of modification anomalies, (2) minimize redesign when
extending, and (3) avoid bias toward any particular access pattern
Access pattern - ANSWER An access pattern is a specification of an access
mode for every attribute of a relation schema, i.e., it is an indication of which
attributes are used as input and which ones are used as output.
What can you do to make your MongoDB 'schema' more effective. - ANSWER
Embed and pre-join anywhere you can.
ACID - ANSWER "Atomicity, Consistency, Isolation, Durability". A set of
properties that guarantee that database transactions are processed reliably.
, database transaction - ANSWER A transaction comprises of a unit of work
performed within a DBMS against a database and treated in a coherent and
reliable way independent of other transactions.
atomicity (ACID) - ANSWER When a series of database operations either all
occur or nothing occurs. Prevents updates to the database occurring only
partially.
consistency (ACID) - ANSWER Guarantee that database constraints are not
violated, particularly once a transaction commits.
isolation (ACID) - ANSWER How transaction integrity is visible to other
users and systems.
durability (ACID) - ANSWER Guarantee that transactions that have
committed will survive permanently.
What are two reasons you might want to keep two documents that are related to
each other one-to-one in separate collections? - ANSWER 1) to reduce the
working set size of your applications, (2) because the combined size of the
documents would be larger than 16MB.
When is it recommended to represent a one to many relationship in multiple
collections? - ANSWER When the "many" is large.
What is the biggest advantage of embedding? - ANSWER Improved read
performance - only one round trip needed to the DB.
GRIDFS - ANSWER Will break-up large file (>64 MB) into chunks and store
chunks in a collection AND will store meta-data about the chunks in another
collection.
What are the costs of indexes? - ANSWER They take up space on disk and
they need to be updated when new records are added.
Which optimization will typically have the greatest impact on the performance
of a database? - ANSWER Adding appropriate indexes on large collections so
that only a small percentage of queries need to scan the collection.
Are you allowed to build MultiKey Indexes when both keys are array? -
ANSWER No, cartesian match too big. However, you can build one if one is an
index and the other isn't.