Привет!
NoSQL
   &
CouchDB
      Епифанов Иван
SQL
SQL
  MySQL
PostgreSQL
  Oracle
  MSSQL
NoSQL
Key-Value:
       Redis
    Membased
     Tarantool
Tokyo cabinet (DBM)
key -> ?????
session_id =>
{
  “serialized”:”data”
}
GRAPH:
     Neo4j
 InfiniteGraph
Вася
       ID

            ID


                  ID
                       ID

Петя   ID



       ID

                 Коля
Document-oriented:
     MongoDB
     CouchDB
{
    "_id": "5b8c0893e90316c578af172e073ed132",
    "type": "speech",
    "title": "Hello NoSQL",
    "author" "iSage",
    "text": "$this",
    "tags": [ "nosql",
               "mongo",
               "couch",
               "whisky",
               "boring"
            ],
    "listeners": [    {
                          "name": "Dmitry",
                          "position": "manager"
                      },
                      {
                          "name": "Sergey",
                          "position": "team lead"
                      },
                      ...
                  ]
}
MapReduce!
[
    document, => map()
    document, => map()
    document, => map()
    document, => map()
]
map = function(document) {
   for (tag in document.tags)
   {
      emit(tag, 1 );
   }
};
[
    “tagname1”: 1,
    “tagname2”: 1,
    “tagname3”: 1,
    ...
    “tagnameN”: 1
]
reduce = function( key , value ) {
   var total = 0;
   for (var i = 0;i < values.length;i++) {
      total += values[i];
   }
   return total;
};
[
    “tagname1”: 56,
    “tagname2”: 42,
    “tagname3”: 13,
    ...
    “tagnameN”: 4
]
36




                           21




    15             5                16




2        13   4        1        5        11
CouchDB
CouchDB
 C + Erlang
CouchDB
 C + Erlang
   ACID
CouchDB
 C + Erlang
    ACID
master-master
CouchDB
 C + Erlang
    ACID
master-master
   JSON
CouchDB
 C + Erlang
    ACID
master-master
   JSON
   HTTP
CouchDB
 C + Erlang
    ACID
master-master
   JSON
   HTTP
  RESTful
POST http://couchdb/database/
{
  “name”: “oh hai”,
  “text”: “well, hello there”
}



<= 5b8c0893e90316c578af172e073ed132
GET
http://couchdb/database/5b8c0893e90316c578af
172e073ed132

<=
{
  “_id”: “5b8c0893e90316c578af172e073ed132”
  “name”: “oh hai”,
  “text”: “well, hello there”
}
PUT
http://couchdb/database/5b8c0893e90316c578af
172e073ed132
{
   “name”: “oh hai”,
   “text”: “well, hello there!”
}



<= 5b8c0893e90316c578af172e073ed132
DELETE
http://couchdb/database/5b8c0893e90316c578af
172e073ed132


<= 200 OK
{
    "_id": "_design/users",
    "language": "javascript",
    "views": {
      "by_mail": {
        "map":
          "function(doc) {
            if (doc.type=='user')
              emit(doc.email,doc);
          }"
      },
      "by_oauth2_id": {
        ...
      },
      "by_oauth1_id": {
        ...
      }
    }
}
+ Прост
+ Понятен
+ JSON
+ Гибкая авторизация
+ ACID
+ full master replication, sharding
+ HTTP/Erlang Server
+ cp -r /my/database/ ~/couch_backups/
+ no structure – no versions!
+ Прост
+ Понятен
+ JSON
+ Гибкая авторизация
+ ACID
+ full master replication, sharding
+ HTTP/Erlang Server
+ cp -r /my/database/ ~/couch_backups/
+ no structure – no versions!

- медленнее mongo, redis, etc.
- http = slow
- MapReduce(MapReduce(MapReduce()))
BONUS
??????

Couchdb