Thursday, May 29, 2014

From SQL to noSQL - Notes

My Notes From: From SQL to noSQL
https://joind.in/10640
Derick Rethans
@derickr

Relational Database
    Row/Colum/Table/Results
    Normalization -> 1NF/2NF/3NF

Key/Val -> MemCache/Redis
Column -> Cassandra/Hadoop
Graph -> neo4j
Document -> CouchDB/MongoDB

Relational Databases value ACI
Theoretical Ideas.

NoSQL solutions value CAP
Consistency/Availability/Partition Tolerance

*Document
Must have an _id field
Schemaless
Documents can have embedded documents or embedded arrays.
Duplicated data in a NoSQL is not a bad thing, but more complicated.

Don't need to create database and schemas.
$m = new MongoClient;
$m->dbname->steps->insert([name => 'derick']);

Use single quotes everywhere.
Query operators start with a $ so that can be obnoxious for PHP.
Greater than or Equal -> '$gte'

Update
Inc, Set, Unset, '$addToSet', '$push'

Use and Atomic value like INC (increment) to avoid race conditions.

No Schema, No Schema Validation, No Checks and Balances.
Having a good model becomes very important.

Don't use values as keys. ie derick => 'twitter user'

Not inforced foriegn keys are allowed
IE: blog post content with blog post views
Article collection and Views collection.
Probably keep a Article View Counter in the article collection rather than counting on the view collection.

Master/Slave Replication
Master/Slave Replication with Failover
Multi-Master Replication
Sharding

Maximum of 12 server in a Replicaset

Eventual Consistency
    Only Gaurantee Perfection by reading from Master
    A delay of seconds to slaves is probably acceptable in most cases.

No comments:

Post a Comment