08 - Databases Flashcards
(35 cards)
reasons for application processes to stop (3)
- hardware/software failure
- need to upgrade or replace hardware
- need to update software
data can be stored in two types
- flat files (txt, csv, binary)
- databases (sql, nosql, relational, document-based)
an open-source document-based database (NoSQL)
mongodb
mongodb features (3)
- high performance
- high availability
- easy scalability
an alternative to Relational Database Management Systems in Web Applications
NoSQL DBs
schema-less collections are good for _____ data
semi-structured data
mongodb works with what type of data storage?
documents in collections
serves as the container for collections
database
contain documents and are schema-less
collections
true/false
several documents within the same collection can only contain the same set of fields
example:
a user can have a first name, middle name and last name, all other users must have all of the fields filled out (first name, middle name, last name)
false, it can be of different sets of fields
true/false
mongodb automatically assignes a primary key for new documents called _key
false, the primary key is labelled as _id
which version/s of mongodb is a version key generated for new documents
in version3+
the version key is incremented after the execution of which functions (2)
save or findOneAndUpdate
basically every update in the document
data relationships are supported using (2) types of documents
- embedded documents
- referenced documents
mongodb commands are centered around ____
queries in the form of documents/JSON
syntax for find command
db.<collectionName>.find(<query>) db['collectionName'].find(<query>)
syntax for update command
db.<collectionName>.find( <query>, <update>, <options> )
syntax for remove command
db.<collectionName>.remove(<query>)
what type of document is this
{ code: "CMSC100", students: 17, sections: [ {section : "EF-1L"}, {section : "EF-2L"} ] }
embedded document, the section documents are embedded in the subject document
advantage of using embedded documents
keeping related data in a single document makes it easy to query and update
disadvantage of using embedded documents
extremely large embedded documents can impact read/write performance
what type of document is this
{ code: "CMSC100", students: 17, sections: [ ObjectId("123456"), ObjectId("7891011") ] }
referenced documents, the section documents are referenced inside a subject document through their object ids
advantages of using referenced documents (2)
- multiple documents can refer to the same external document
- avoids the pitfalls of excessively large embedded documents
disadvantage of using referenced documents
requires additional querying that many developers want to avoid