924
Lectures Watched
Since January 1, 2014
Hundreds of free, self-paced university courses available:
my recommendations here
Peruse my collection of 275
influential people of the past.
View My Class Notes via:
Receive My Class Notes via E-Mail:

VIEW ARCHIVE


Contact Me via E-Mail:
edward [at] tanguay.info
Notes on video lecture:
Basic Querying in MongoDB
Choose from these words to fill the blanks below:
asciibetically, JSON, string, methods, Remove, database, Find, pleasant, syntax, structured, current, removing, JavaScript, embedded, objects, previous, Perl
CRUD/Mongo/SQL terminology
Create = Insert = INSERT
Read =          = SELECT
Update = Update = UPDATE
Delete =              = DELETE
MongoDB's CRUD operation exist as               /functions in programming language APIs
MongoDB does not have a separate language that needs to be                  as strings inside code that operates on MongoDB
as a developer, you manipulate the database using methods on               , similar to a object mapping with RDBMS
this makes database I/O with MongoDB relatively                  for programmers
the Mongo shell
the Mongo shell is an interactive                      interpreter
pay attention to the version number when you log in
you can type in javascript at the command line
up arrow retrieves                  commands
ctrl-a to front of line
built-in helpers
help
help keys
command completion
basic javascript variable assignment
BSON
fundamental record type is a nested dictionary of key/value associations
javascript objects, because they are in dictionary/         form, can be saved directly into the database
JSON was inspired by the              of JavaScript
MondoDB does not use this stringy syntax
http://bsonspec.org ; BSON spec ; BSON is binary JSON, has data types that go beyond JSON, e.g. datetime, 32 and 64 bit integer type, etc.
in the shell we use JavaScript and we can force the types of numbers
NumberInt(1)
NumberLong(1)
but be careful with languages such as JavaScript or          which can't represent all of the types that BSON can represent
new Date() or ISODate(...)
so you can faithly handle all of the data that comes out of the database by casting it like this:
inserting docs
the shell has a variable named db which is a handle to the                database
collections are properties of the                 , e.g. db.people.insert(doc)
when you insert a document, it gets a unique field "_id"
different from other databases, the primary key is immutable
you could similate changing the id by                  a document, and inserting it again so it gets another id
_id is the primary key
_id is always ObjectId made up of date, machine, process id on computer, and a counter, so these ideas are globally unique
if you don't insert an _id, then one will be generated for you
finding documents
db.fruit.find() will find all
db.people.findOne({name:"Jones"})
the query is presented to the server in the form of a                      document
the second argument allows you to specify which fields you want to get back, true or false
_id is included by default
find
fill database so we can do some queries:
db.people.find() to see them all
type it iterate through the results
shell is keeping these results open
cursor is on the server, will clear it in 10 minutes
dp.people.find().pretty() to see results formatted
when multiple fields are given in the first parameters of find(), then it assumes AND
these are called "query by example" queries
query operators
db.scores.find({ score : { $gt : 95, $lte : 95}) (greater-than, less-than-or-equal)
&gt, &lt etc. can also be applied to strings
currently sorts                             
future versions should have better support
all comparison operations are strongly typed
if you filter by less than "A", you will not get numbers
generally, you should not mix types in one named field, e.g. store 42 in a name
here the third item will not work since comparisons are case sensitive
querying on whether field exists
you can check for a type, use the BSON specifications, so              = 2:
do.people.find({name:{$type:2}})
you can also use regexs:
all names that end with "e"

Vocabulary:

asciibetical, adj. sorting words according to their ASCII codes instead of intuitionally according to the alphabet  "Asciibetical sorting serves the needs of the computer and the compiler, but not the human being."
MongoDB Introduction
Installing MongoDB/node.js and Hello Worlds
MongoDB, node.js, Express and SWIG
Basic Querying in MongoDB
More Querying in MongoDB
MongoDB CRUD via Node.js
Comparing RDBMS and MongoDB Schema Design