NoSQL and MongoDB Flashcards

1
Q

Describe the hierarchy of a typical NoSQL database

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The minimal code required to insert a document in a MongoDB database is:

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When are databases and collections created?

A

When the first document is inserted into them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why am I getting err_connection_refused when trying to use pymongo?

A

Because MongoDB Community Server is not running in the background; run it first

How well did you know this?
1
Not at all
2
3
4
5
Perfectly