MongoDB Flashcards

1
Q

what is MongoDB?

A

A NoSQL (not only sql) database management system

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

what does not only sql mean?

A

instead of storing data in tables with sql, we store data that is frequently accessed together in the same document. document = row in sql

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

how is data stored in mongodb documents?

A

data in each document is stored in field-value pairs
technically bson (binary javascript object notation)

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

how do you create a new database?

A

use [newdatabasename]

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

how do you show all current databases? (2)

A

show dbs

*note that empty dbs will not show up

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

how do you use a database?

A

use [databasename]

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

how do you add a collection to a database?

A

db.createCollection(“collection_name”)

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

how do you drop (delete) the current database? (shell)

A

navigate to the database you want to delete, then db.dropDatabase()

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

how do you insert a document into a database?

A

db.collection_name.insertOne({name:”Spongebob”, age:30, gpa:3.2})

note: a document is contained within curly brackets and can contain as many field-value pairs as you’d like}

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