Untested Chapter Notes Flashcards
CAP theory
Consistency
* All replicas contain the same version of data
* Client always has the same view of the data(no matter what node)
Availability
* System remains operational on failing nodes
* All clients can always read and write
Partition tolerance
* Partition tolerance means that entire clusters can still work even if a network
partition causes communication interruption between nodes.
* System remains operational on system split(communication malfunction)
* System works well across physical network partitions
What is Oracle RAC
Oracle Real Application Clusters (RAC) allow
customers to run a single Oracle Database across
multiple servers to maximize availability and enable
horizontal scalability, while accessing shared storage.
Sharding
Uses range-based partitioning to distribute documents based on a
specific shard key
* Shard key: a single indexed field for now
How does NoSQL differ from RDBMS?
- Looser schema definition
- Designed to handle distributed, large databases
- Query language through the API
- Relaxation of the ACID (Atomicity, Consistency, Isolation, Durability)
properties
SQL Database is horizontally scalable while NOSQL is vertically scalable T/F
False
Benefits of NoSQL
- Elastic Scaling
- DBA Specialists
- Big Data
- Flexible data models
- Economics:
- No SQL: clusters of cheap commodity servers to manage the data and transaction volumes- Cost per gigabyte or transaction/second for NoSQL can be lower than the cost for a RDBMS
Drawbacks of NoSQL
- Support: New open source projects with startup support; no reputation
- Maturity: still implementing their basic feature set
- Administration: no administrator necessary however NoSQL still requires effort to maintain
- Lack of Expertise
- Analytics and Business Intelligence
MongoDB
Developed in C++ by 10gen founded in 2007
NoSQL database
* Hash-based, schema-less database
* No Data Definition Language
* Uses BSON format: Binary of JSON
* Supports APIs (drivers) in JavaScript, Python, Ruby, Perl, Java, C#, C++.
JSON
JavaScript Object Notation – language independent
* JSON is a lightweight format for storing and transporting data.
JSON Data types
a string, a number, an object (JSON object), an array, a boolean, a null
BSON
a binary-encoded serialization of JSON-like documents.
Advantages of MongoDB
Speed, Sharding, Flexible Database, Horizontal Scalability
Disadvantages of MongoDB
Joins not supported, limited data size
Applications of MongoDB
- Web Content Management
- Real-Time Analytics
- Internet of Things (IoT)
Is MongoDB ACID compliant?
No
JSON data type cannot be a function, a date, undefined T/F
True
JSON Data Structures
Object: Collection of name-value pairs
Array: List of values
JSON Syntax
Begins with { (left brace) and Ends with }(right brace)
* Each name is followed by :(colon)
* Name/value pairs are separated by ,(comma)
* Square brackets hold arrays
BSON – Basic types
Basic types:
* byte 1 byte (8-bits)
* int32 4 bytes (32-bit signed integer, two’s complement)
* int64 8 bytes (64-bit signed integer, two’s complement)
* uint64 8 bytes (64-bit unsigned integer)
* double 8 bytes (64-bit IEEE 754-2008 binary floating point)
* decimal128 16 bytes (128-bit IEEE 754-2008 decimal floating
point)
BSON - Element - Structure - Type Selector
- 0x01 = double
- 0x10 = 4byte integer
- 0x12 = 8byte integer
- 0x08 = boolean
- 0x0A = null
- 0x09 = datetime
- 0x11 = timestamp
Collection and Documents MongoDB
Collection
* Collection of documents, usually of a similar structure
* Document
* MongoDB document = one JSON object (BSON)
* Each document has a unique idenƟfier (primary key)
* – Technically realized using a top-level _id field
MongoDB: Object Hierarchy
A MongoDB database may have one or
more ‘collections’.
* A collection may have zero or more
‘documents’.
* A document may have one or more
‘fields’.
MongoDB documents are not internally stored in BSON format and the maximum allowed size is 15 mb (t/f)
False
Semi-structured model
is a database model where there is no
separation between the data and the schema
Mongod (Astaghfirullah)
is the primary daemon process of MongoDB system. It handles data
requests, manages data access, and performs management operations.
You can have multiple mongos for the system (T/F)
False, you can have one mongo for the whole system no matter how many mongods.
You also can have one local mongos for every client if you wanted to
minimize network latency.
CRUD Operations
Create, read, update, delete; No data definition language (DDL) in MongoDB.
MongoDB is schemeless.
MongoDB read operations
find(): primary method to select documents from a collection
* It is identical to “select * from table_name;”
* findOne(): returns only a single object
MongoDB update operations
update(): corresponds to the UPDATE operation in SQL
* updateOne()
* Updating values uses the $set operator.
MongoDB insert
Insert(): similar to SQL insert command
* save(): performs the same as insert()
* insertOne()
* insertMany()
MongoDB delete
Remove(): similar to SQL delete
* deleteOne()
* deleteMany()
* Note: it seems that MongoDB does not have delete() function
What does $unset do
deletes a particular field