NoSQL and MongoDB Flashcards
Describe the hierarchy of a typical NoSQL database
A database contains collections
Each collection contains documents.
Each document consists of key-value pairs.
Documents can be nested, i.e. the value in a document can be another document.
The minimal code required to insert a document in a MongoDB database is:
import pymongo
dbname = 'mydb' # use actual database name collname = 'mycoll' # use actual collection name
client = pymongo.MongoClient()
db = client[dbname]
coll = db[collname]
coll.insert_one(doc) # Replace with appropriate document, or use other methods
When are databases and collections created?
When the first document is inserted into them
Why am I getting err_connection_refused when trying to use pymongo?
Because MongoDB Community Server is not running in the background; run it first