MongoDB Flashcards
what is MongoDB?
A NoSQL (not only sql) database management system
what does not only sql mean?
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 is data stored in mongodb documents?
data in each document is stored in field-value pairs
technically bson (binary javascript object notation)
how do you create a new database?
use [newdatabasename]
how do you show all current databases? (2)
show dbs
*note that empty dbs will not show up
how do you use a database?
use [databasename]
how do you add a collection to a database?
db.createCollection(“collection_name”)
how do you drop (delete) the current database? (shell)
navigate to the database you want to delete, then db.dropDatabase()
how do you insert a document into a database?
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}