Quiz
- I'm still a bit confused
That's understandable. We've made quite a departure from our earlier work. But you'll get there. Feel free to stop by office hours and talk if you'd like to hear it again.
- mongoDB
MongoDB is a kind of database, where the data are in relatively unstructured form (JSON). You can think of it the way you think of library of valuable books, where we don't get to wander the stacks on our own, but instead we have to ask the librarian to get a book for us, or return it to the shelf.
We always have to connect to the database and issue queries to get the information we want.
- MQL and URIs
MQL is the Mongo Query Language. So, it encompasses the comparison operators (such as
$lt
) and boolean operators (such as$and
).URI are essentially synonymous with URL: a uniform resource identifier/locator. We use them to specify where in the world our MongoDB database is.
mongodb+srv://scott:password@cluster0.dn6vs.mongodb.net/?retryWrites=true&w=majority
You honestly won't have to worry about this much. Just make sure you do
source ~/.cs304env.sh
Then, your URI is the value of $MONGO_URI. You can do
echo $MONGO_URI
If you want to look at it.
- I'm still a little bit unclear about the difference between "uid" and "_id." It seems like they have similar purpose but when do we use one over another?
Yes, they do have a similar purpose. The
_id
is generate by MongoDB so that we always have it. It's not the most user-friendly value, but it's reliable.The
uid
is generated in a different way, and could reasonably be used in other databases/collections. - How are JSON documents different from javascript dictionaries?
Not much difference! It's one reason I began in the front end, so that you were comfortable with JSON before working with MongoDB.
JSON is slightly restricted compared to JS dictionaries. For example, you can store a function in a JS dictionary (that's how methods work), but functions aren't allowed in JSON. Strings, numbers, booleans, arrays and dictionaries. That's it.
- Probably more about BSON? What distinguishes MongoDB's storage of data in BSON from traditional SQL databases? Can we transform JSON into BSON?
BSON is just a binary representation of JSON. Using binary is slightly more compact and efficient, but less readable. MongoDB uses BSON internally. We won't have to convert, though if you wanted to, there are online tools
JSON is very different from traditional SQL databases, where we have to specify lengths of strings, bytes of integers, etc. JSON is much more flexible.
- I hope we could practice using projection and sort.
Sure, let's plan to do that.
- Is there a way to utilize regular expressions dynamically as opposed to on a case to case basis?
I'm not sure I understand this question. I can give some examples of regular expressions. For example:
grep ^cs[0-9]*: /etc/passwd
- Complex queries
Meaning the aggregation pipeline? We'll get there later.
- This reading was clear!
Amazing!