Databases Flashcards
One of the goals in web development is data __________.
persistence
Application processes stop at some point for 3 reasons:
- Hardware/software failure
- Need to upgrade or replace hardware
- Need to update software
Data can be stored in (2):
- Flat files
- Databases
A NoSQL, open-source document based database.
MongoDB
3 Features of MongoDB
- High Performance
- High Availability
- Easy Scalability
Working with _______ is commonplace in today’s programming languages.
objects
Why not save objects in the datastore in a similar format?
Sabi ni chatgpt:
1. Datastore Efficiency and Compatibility
In-memory objects often contain methods, type annotations, and references unsuitable for storage.
Datastores are optimized for simpler, serializable formats like JSON, BSON, or SQL rows.
- Serialization Requirements
Data needs to be converted into a storable format (like maps or plain values). This process often drops non-serializable fields or complex types. - Cross-Platform or Cross-Language Interoperability
Saving data in a universal format (e.g., JSON) ensures that different clients (mobile, web, backend) can read it. - Avoiding Redundancy or Circular References
Object graphs in memory might have circular references or complex nesting. Flattening the structure avoids recursion and storage issues. - Storage Constraints
Some datastores (like Firebase Realtime Database or Firestore) have size limits or structural expectations that influence data shape.
Schema-less collections are good for _______________ data
semi-structured
MongoDB’s speed is good for applications requiring _____________ data.
real-time
Serve as the container for collections.
Databases
Contain documents and are schema-less
Collections
Units in MongoDB collections are JSON-like objects called ___________.
documents
In MongoDB, new documents are automatically assigned a primary key called ________.
_id
In version 3+ of MongoDB there is also a generated version key _____.
_v
The _v of a document is incremented after the execution of certain functions such as ______ or ____________.
save or findOneAndUpdate
Data relationships are supported using _______________ or _____________.
embedded documents or referenced documents
MongoDB commands are centered around _________ which take the form of documents/JSON.
queries
_________ documents keep related data together.
Embedded
What is the advantage of embedded document?
Easier to query and update
Disadvantage of embedded documents
Large embedded documents can impact read/write performance
__________ documents take a normalized approach similar to Relational DBs.
Referenced
Documents in other collections may reference them using an ___________.
Object ID or any identifying field
Advantages of Referenced Documents
- Multiple documents can refer to the same external document
- Avoid the pitfalls of excessively large embedded documents.
Disadvantage of Referenced Document
Require additional querying that many developers want to avoid