Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CouchDB: A Database That Completely Embraces Th...

CouchDB: A Database That Completely Embraces The Web

Short overview of NoSQL, document-oriented databases and CouchDB as a representative of both.

Christian Liebel

February 18, 2016
Tweet

More Decks by Christian Liebel

Other Decks in Programming

Transcript

  1. 1 A DATABASE THAT COMPLETELY EMBRACES THE WEB – DHBW

    CAS Heilbronn – 18.02.2016 Christian Liebel @chris_liebel
  2. 3 . 1 NOSQL DATABASES Not only SQL Structured Query

    Language (SQL) is not the only/preferred database language or unavailable Alternative to Relational Database Management Systems (RDBMS) Data manipulation using object-oriented APIs Open-source
  3. 4 . 1 DOCUMENT-ORIENTED DATABASES Main category of NoSQL databases

    Schemaless, weakly typed Database: Collection of documents Distributed, scalable RESTful API
  4. 4 . 2 REST Representational State Transfer Architectural style, no

    standard Example using HTTP (Hypertext Transfer Protocol) methods Collections: h t t p : / / e x a m p l e . c o m / u s e r s / Entities: h t t p : / / e x a m p l e . c o m / u s e r s / u s e r 1 Method GET PUT POST DELETE Action Read Create/Update Insert Delete
  5. 4 . 3 WHERE TO USE Prototypes Agile, dynamic projects

    Scalable, highly-available applications
  6. 5 . 1 JSON JavaScript Object Notation Data format derived

    from JavaScript Lightweight Text-based Human-Readable
  7. 5 . 2 JSON (SAMPLE) { " n a m

    e " : " P e t e r " , " a g e " : 3 4 , " b o o k s " : [ { " t i t l e " : " M a k e N o i s e " , " a u t h o r " : " P o p e F r a n c i s " } , { " t i t l e " : " H a r r y P o t t e r a n d t h e C h a m b e r o f S e c r e t s " , " a u t h o r " : " J . K . R o w l i n g " } ] }
  8. 6 . 1 COUCHDB Open-Source Documented-Oriented NoSQL Database Uses JSON

    as data format Offers an RESTful API served over HTTP Supports replication https://couchdb.apache.org
  9. 6 . 2 COUCHDB Eventually consistent (= highly available &

    partition tolerant) Fault-tolerant storage engine Distributed Scaling (Map/Reduce) Powers npm (Node.js Package Manager)
  10. 6 . 3 FAUXTON UI Name Size # of Docs

    Update Seq Actions _replicator 6.1 KB 1 1   _users 8.1 KB 1 1   students 4.6 KB 3 3   Databases  Active Tasks  Config  Replication  Documentation(http://docs.couchdb.org/en/latest/intro/api.html#documents)  Admin Party!  Verify  Fauxton on PouchDB Server (https://github.com/pouchdb/pouchdb-server) v. 1.0.2 « 1 » Databases  API URL  Add New Database Database name 
  11. 7 . 1 USAGE Any REST client ( , …)

    (Browsers) (Java) (C#) Postman PouchDB CouchDB4J LoveSeat
  12. 7 . 2 POUCHDB JavaScript implementation of CouchDB Runs cross-platform

    (i.e. in the browser or Node.js) Emulates CouchDB’s API Data is stored locally (IndexedDB/Web SQL) Sync to CouchDB/offline support Asynchronous API (Promise-based) http://pouchdb.com
  13. 7 . 3 POUCHDB (Direct usage, no local sync) v

    a r d b = n e w P o u c h D B ( ' h t t p : / / l o c a l h o s t : 5 9 8 4 / s t u d e n t s ' ) ; v a r s t u d e n t = { _ i d : " n e u s t u d e n t " , f i r s t N a m e : " " , n a m e : " " , a g e : 3 7 } ; d b . p u t ( s t u d e n t ) . t h e n ( f u n c t i o n ( ) { r e t u r n d b . g e t ( s t u d e n t . _ i d ) ; } ) . t h e n ( f u n c t i o n ( r e s ) { a l e r t ( J S O N . s t r i n g i f y ( r e s ) ) ; } ) ; R u n!