CouchDB - Sai Divya Panditi - Priyanka Yechuri. Overview Introduction SQL vs CouchDB CouchDB Features CouchDB Core API Futon Security Application.

Slides:



Advertisements
Similar presentations
Give it a REST already Arnon Rotem-Gal-Oz VP R&D xsights
Advertisements

Other Web Application Development Technologies. PHP.
The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
WebGoat & WebScarab “What is computer security for $1000 Alex?”
With jQuery and AJAX Doncho Minkov Telerik Corporation Technical Trainer.
B.Sc. Multimedia ComputingMedia Technologies Database Technologies.
HTTP Overview Vijayan Sugumaran School of Business Administration Oakland University.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
CVSQL 2 The Design. System Overview System Components CVSQL Server –Three network interfaces –Modular data source provider framework –Decoupled SQL parsing.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
NoSQL Databases - CouchDB By Tom Sausner. Agenda Introduction Review of NoSQL storage options  CAP Theorem  Review categories of storage options CouchDB.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
Beyond the UI Using Tools to Improve Testing Jeremy Traylor
JavaScript & jQuery the missing manual Chapter 11
© 2011 Autodesk Automating Autodesk® Revit® Server Rod Howarth Software Development Manager – Bornhorst + Ward.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
European Space Astronomy Centre (ESAC) Villafranca del Castillo, MADRID (SPAIN) Aurélien Stébé Homogeneous Access to Tabular Data Beijing, China - May.
MongoDB An introduction. What is MongoDB? The name Mongo is derived from Humongous To say that MongoDB can handle a humongous amount of data Document.
CSC 2720 Building Web Applications Getting and Setting HTTP Headers (With PHP Examples)
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
REST.  REST is an acronym standing for Representational State Transfer  A software architecture style for building scalable web services  Typically,
Is Apache CouchDB for you?
CollectionSpace Service REST-based APIs June 2009 Face-to-face Aron Roberts U.C. Berkeley IST/Data Services.
Unit 07 : AJAX, JSON, REST and CouchDB
PHP meets MySQL.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Goodbye rows and tables, hello documents and collections.
Moohanad Hassan Maedeh Pishvaei. Introduction Open Source Apache foundation project Relational DB: SQL Server CouchDB : JSON document-oriented DB (NoSQL)
© Copyright 2013 STI INNSBRUCK
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
Putting it all together Dynamic Data Base Access Norman White Stern School of Business.
 2004 Prentice Hall, Inc. All rights reserved. 1 Segment – 6 Web Server & database.
Chapter 6 Server-side Programming: Java Servlets
Introduction to the SharePoint 2013 REST API. 2 About Me SharePoint Solutions Architect at Sparkhound in Baton Rouge
Security Attacks CS 795. Buffer Overflow Problem Buffer overflows can be triggered by inputs that are designed to execute code, or alter the way the program.
1 Seminar on Service Oriented Architecture Principles of REST.
DM_PPT_NP_v01 SESIP_0715_JR HDF Server HDF for the Web John Readey The HDF Group Champaign Illinois USA.
A FIRST TOUCH ON NOSQL SERVERS: COUCHDB GENOVEVA VARGAS SOLAR, JAVIER ESPINOSA CNRS, LIG-LAFMIA, FRANCE
Google Data Protocol Guy Mark Lifshitz. Motivation Google’s Mission: – Organize the world’s information – Make information universally accessible – Provide.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
Introduction to Web Services
1 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 2: REST Details and Patterns Some.
ICM – API Server & Forms Gary Ratcliffe.
RESTful Web Services What is RESTful?
NoSQL Or Peles. What is NoSQL A collection of various technologies meant to work around RDBMS limitations (mostly performance) Not much of a definition...
NSF DUE ; Wen M. Andrews J. Sargeant Reynolds Community College Richmond, Virginia.
Web Technologies Lecture 10 Web services. From W3C – A software system designed to support interoperable machine-to-machine interaction over a network.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
Web Services Essentials. What is a web service? web service: software functionality that can be invoked through the internet using common protocols like.
Modern web tools and midas Ben Smith TRIUMF Midas workshop – July 2015 Ben Smith - Modern web tools and Midas 1 15/07/15.
REST API Design. Application API API = Application Programming Interface APIs expose functionality of an application or service that exists independently.
Introduction to Database Programming with Python Gary Stewart
COMP 430 Intro. to Database Systems MongoDB. What is MongoDB? “Humongous” DB NoSQL, no schemas DB Lots of similarities with SQL RDBMs, but with more flexibility.
- Sai Divya Panditi - Priyanka Yechuri
COMP 430 Intro. to Database Systems
Business Directory REST API
The Client-Server Model
Data Virtualization Tutorial: Introduction to SQL Script
Content from Python Docs.
z/Ware 2.0 Technical Overview
Data Virtualization Tutorial… CORS and CIS
PHP / MySQL Introduction
NOSQL databases and Big Data Storage Systems
WEB API.
relational thoughts on NoSql
Chengyu Sun California State University, Los Angeles
Presentation transcript:

CouchDB - Sai Divya Panditi - Priyanka Yechuri

Overview Introduction SQL vs CouchDB CouchDB Features CouchDB Core API Futon Security Application

Overview Demo Code Advantages DisAdvantages Iris Couch Conclusion References

Introduction Created By : Damien Katz Year : 2005 Language : Erlang License : Apache Software Foundation(2008)

Introduction... NoSQL Database.....Uses Map/Reduce queries written in javascript

NoSQL Databases Schema-Free Distributed Open Source Horizontally Scalable Easy Replication Support

NoSQL Timeline

Document-Oriented DBMS Data is stored in documents......and not in relations like an RDBMS

SQL vs CouchDB SQLCouchDB RelationalNon-Relational TablesDocuments with types Rows and ColumnsDocument Fields SQL Query EngineMap / Reduce Engine

CouchDB Features Data Representation - Using JSON Interaction - Futon / CouchDB API Querying - Map / Reduce Design Documents - Application code(Language : Javascript) Documents can have attachments

JSON Stands for Javascript Object Notation Derived from Javascript scripting language Used for representing simple data structures and associative arrays

JSON..... Example: { "firstName": "John", "lastName": "Smith", "age": 25, "phoneNumber": [ { "type": "home", "number": " " }, { "type": "fax", "number": " " } ] }

CouchDB Core API (Command Line Utility ) Server API Database API Document API Replication API

HTTP API Messages are self-described via HTTP Headers and HTTP Status Codes. URIs identify resources. HTTP Methods define operations on the resources.

HTTP Request Methods MethodDescription PUT GET POST DELETE COPY PUT requests are used to create new resources where the URI of the request is different to the resource that is to be created. GET requests are used to request data from the database. POST requests are used to update the existing data, at the same resource the URI is requested from. DELETE requests to delete databases and documents. Copies one resource to another resource.

HTTP Status Codes Status CodeDescription 200 (OK) 201 (Created) 304 (Not Modified) 400 (Bad Request) 404 (Not Found) 405 (Method Not Allowed) 409 (Conflict) 412 (Precondition Failed) 500 (Internal Server Error) The request was successfully processed. The document was successfully created. The document has not been modified since the last update. The syntax of the request was invalid. The request was not found. The request was made using an incorrect request method. The request failed because of a database conflict. could not create a database- a database with that name already exists. The request was invalid and failed, or an error occurred within the CouchDB server.

Curl Command - Server API Command to check if CouchDB is working at all? curl Response : {"couchdb":"Welcome","version":"0.10.1"}

Curl Command - Database API Command to get a list of Databases : curl -X GET Command to create a Database : curl -X PUT Curl's -v option : curl -vX PUT Command to destroy a Database : curl -X DELETE

Curl Command - Document API Command to create a document : curl -X PUT 6ert2gh45ji6h6tywe324743rtbhgtrg \ -d '{"title":"abc","artist":"xyz"}' Command to get a UUID : curl -X GET Command to retrieve a Document : curl -X GET 6ert2gh45ji6h6tywe324743rtbhgtrg

Curl Command - Document API Command for attachments : curl -vX PUT 6ert2gh45ji6h6tywe324743rtbhgtrg/ \ artwork.jpg?rev= H "Content-Type: image/jpg" To view the image in the browser, URL is : tywe324743rtbhgtrg/artwork.jpg

Curl Command- Replication API Command to replicate a Database : curl -vX POST _replicate \ -d '{"source":"albums","target": "albums_replica"}'

Futon Built-in admin interface Access to all CouchDB features Create and Destroy databases Create, View and Edit Documents Compose and run Map / Reduce Views Replicate a Database

Futon Interface Demo...

Design Documents Contains application code They are like normal json documents but prefixed by _design/ CouchDB looks for views and other application functions here...

Used for extracting data we need for a specific purpose Example : function(doc){ if(doc.Bname) { emit(doc.id,doc.Bname); } Views

View Functions... Map - single parameter - doc emit(key,value) - built-in function Results of emit() are sorted by key We query the views to produce the desired result When we query a view, it's run on every document in the database for which view is defined View result is stored in a B-tree

View Functions… B-tree for the view is built only once and all the subsequent queries will just read the B-tree instead of executing the map function again Used to find documents by any value or structure that resides in them Using the URI, we can retrieve the exact data we need. For Example : /books/_design/docs/_view/by_Bname?key="Circuits"

Map Functions For Example : Consider the following documents Document-1 id : 1 Bname : Oracle Category : CS Author : abc Edition : 2007 Document-2 id : 2 Bname : Networks Category : CS Author : xyz Edition : 2001 Document-3 id : 3 Bname : Circuits Category : Electronics Author : abcd Edition : 2004 Document-4 id : 4 Bname : AI Category : CS Author : pqrs Edition : 2010

Map Functions… Output : KeyValue 1Oracle 2Networks 3Circuits 4AI

Map Functions… Map Function : map:function(doc) { emit(doc.Bname, doc.id); } Output : AI4 Circuits3 Networks2 Oracle1

Reduce Function This function operates on the sorted rows emitted by map view functions. Predefined Reduce Functions: _sum, _count etc. Example: function(keys,values){ return sum(values); //gives aggregate values }

Security Database Admins Validation Functions

Database Admin Demo…

Validation Function Uses the function validate_doc_update(). If the validation function raises an exception, the update is denied else the updates are accepted. Document validation is optional.

Who uses CouchDB?

Application GSUBooks.com

add.js: $(document).ready( function() { //Event handler crud stuff $('input#addId').click(function(e) { if ($('#bookId').val().length == 0) { return; } var bookdoc = { booknm: $('#bookId').val(), authornm: $('#authorId').val(), category: $('#categoryId').val(), edition: $('#editionId').val(),quantity: $('#quantityId').val() } Code - add.js

Code - add.js... db.saveDoc(bookdoc, { success: function(resp) { checkList(); //refreshes the database with new book } });

Code-delete.js delete.js $(document).ready ( function() { $('input#borrowId').click(function(e) { if ($('#idId').val().length == 0) { return; } var bookdoc = { _id: $('#idId').val(), _rev: $('#revId').val() } db.removeDoc(bookdoc, { success: function(resp) {

Code-delete.js checkList(); //refreshes the database with the remaining books alert("Book has been borrowed Successfully!!"); }}); clearDocument(); }); }); function clearDocument() { $('#idId').val(''); $('#revId').val(''); $('#bookId').val(''); $('#authorId').val(''); $('#categoryId').val(''); $('#editionId').val(''); $('#quantityId').val(''); };

Code - Update.js update.js $(document).ready(function() { $('input#updateId').click(function(e) { if ($('#idId').val().length == 0) { return; } var bookdoc = { _id: $('#idId').val(), _rev: $('#revId').val(), booknm: $('#bookId').val(),

update.js... authornm:$('#authorId').val(), category:$('#categoryId').val(), edition:$('#editionId').val(), quantity:$('#quantityId').val() } db.saveDoc(bookdoc, { success: function(resp) { checkList(); } });

display.js $(document).ready(function() { checkList(); }); function checkList() { $("table#itemData").empty(); db.view("myfirstDesign/myfirstView", { success: function(data) { $('table#itemData').append(' Book Name Author Name <font color="black">Category Edition Code - Display.js

Quantity '); data.rows.map(function(row) { $('table#itemData').append(' ' +row.value.authornm +' ' +row.value.category +' ' +row.value.edition +' ' +row.value.quantity +' '); $('#'+row.value._id).click(function() { $('#idId').val(row.value._id);

Code - Display.js $('#revId').val(row.value._rev); $('#bookId').val(row.value.booknm); $('#authorId').val(row.value.authornm); $('#categoryId').val(row.value.category); $('#editionId').val(row.value.edition); $('#quantityId').val(row.value.quantity); return false; }); }); } }); }

Advantages / DisAdvantages Features Not easy to learn especially if the user is familiar with SQL Security is weak Temporary views on large datasets are very slow. Replication of large databases may fail Documents are quite large as the data is represented using “JSON” format

Iris Couch Cloud CouchDB hosting Free service

Iris Couch Demo…

References CouchDB - The Definitive Guide, J. Chris Anderson, Jan Lehnardt & Noah Slater Beginning CouchDB, Joe Lennon

Thank You...