Test 2 Study Guide
The second test of the course covers Module 2: Working with Databases. You can review the material on the following pages:
- Working with Databases (Overview)
- Introduction to NoSQL
- Introduction to MongoDB
- CRUD Operations
- MongoDB with Node.js
- Data Modelling and Queries
Key Concepts
In addition to reviewing the content above, you should feel comfortable answering the following questions:
- What is the difference between a SQL database and a NoSQL database?
- What are the three levels of organization in MongoDB (from largest to smallest)?
- What is an
ObjectId, and what is the_idfield used for? - What is the difference between
findandfindOne? What doesfindOnereturn if nothing matches? - What does a query filter do, and what happens when you pass multiple fields in a single filter?
- What does each of the following update operators do:
$set,$unset,$inc,$push,$pull? - What happens if you pass a plain object to
updateOnewithout using an update operator like$set? - Why do database operations in Node.js require
asyncandawait? - What is the purpose of
try/catch/finallywhen working with database code? Why isfinallya good place to close the connection? - How does
find()behave differently in Node.js compared to the Mongo shell? What method do you call to get the results as an array? - What is the difference between embedding and referencing when designing a document schema? Give an example of when each is appropriate.
- Write a query that finds all documents where a numeric field is greater than a given value.
- What is the difference between
$andand$or? When do you need explicit$andversus relying on implicit$and? - What do
sort,limit, andskipdo? How can they be combined for pagination? - What is projection, and why would you use it?