블로그 이미지
LifeisSimple

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Notice

2010. 12. 29. 17:30 Brain Trainning/NoSQL
좀 오래되긴 했지만... 그래도 간단하게 잘 설명된것 같습니다. 


To illustrate how easy and straightforward writing applications for CouchDB is, we are going to build a simple todo-list application in Javascript. You should be familiar with HTMLand Javascript and the DOM. You do not need any Ajaxexperience. Although we are going to use it, all will be abstracted away.

The interface is quite plain, as is the functionality. This is only to demonstrate how to work with CouchDB and not meant as a real application. We could turn this into something nice with some spit & polish.

Say hello to our todo app

How it works

We take a top level view here, working our way from the user’s perspective down to the actual code. This ensures we do not screw up the application for the user by mapping its inner workings to the user’s model.

When you open the app you are greeted with an empty input box and a list of todos (or no todos, in case you were working hard). You can type in a single-line todo item, hit enter and that line appears on top of the list. Finally, the input field gets reset and you can enter another item. To mark an item done, click the X next to it. It will disappear.

Boy this looks trivial, but it captures the essence of a todo list. There are plenty of opportunities how to improve things, but let’s nail the basics first.


....


posted by LifeisSimple
2010. 12. 29. 14:29 Brain Trainning/NoSQL


Document Databases Compared: CouchDB, MongoDB, RavenDB

by Alex Popescu

Brian Ritchie has two posts (☞ here and ☞ here) covering three document databases: CouchDB, MongoDB, and RavenDB concluding with the matrix below:

But before using this as a reference material there are a couple of corrections needed:

They have some special characteristics that make them kick some serious SQL.

  • Objects can be stored as documents: The relational database impedance mismatch is gone. Just serialize the object model to a document and go.
  • Documents can be complex: Entire object models can be read & written at once. No need to perform a series of insert statements or create complex stored procs.
  • Documents are independent: Improves performance and decreases concurrency side effects
  • Open Formats: Documents are described using JSON or XML or derivatives. Clean & self-describing.
  • Schema free: Strict schemas are great, until they change. Schema free gives flexibility for evolving system without forcing the existing data to be restructured.
  • Built-in Versioning: Most document databases support versioning of documents with the flip of a switch.
  1. Judging by the growing number of document database mapping tools, I’m not sure impedance mismatch is really gone (related to 1st point above)
  2. Using embedded format is not always the best solution for mapping relationships and other more complex data structures. (related to 2nd and 3rd points above)
  3. Versioning is an extra-feature that is not fundamental to document databases. MongoDB and CouchDB do not support it by default, but there are different solutions available

Related to the matrix comparison:

  1. Versioning is not supported by either MongoDB and CouchDB. MVCC should not be confused for document versioning
  2. Sharding: CouchDB doesn’t support sharding out of teh box. There are different solutions for scaling CouchDB, using Cloudant Dynamo-like scaling solution for CouchDB, or evenrunning CouchDB with a Riak backend
  3. Replication: both MongoDB and CouchDB support master/master and master/slave
  4. Security: check firstly the NoSQL databases and security post and decide for yourself and the “basic” level is enough for your app

posted by LifeisSimple
2010. 12. 29. 14:23 Brain Trainning/NoSQL

출처 : http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/mongodb-vs-sql-server-insert-comparison

내용을 보면 이전 비교에서는 단일 Transaction 으로 하지 않아서 SQL 서버가 느렸지만 하나의 단일 Transaction으로 묶게 되면 로그가 줄어들어 속도가 빨라진다라는 내용인 것 같습니다. 그렇지만 후자의 경우는 실 서비스에서는 일어나지 않죠. 따라서 아무래도 단순 Insert 의 경우는 NoSQL 이 압승인것 같습니다. 

Lee Everest created a post named MongoDB vs. SQL Server - INSERT comparison where he compared inserting 50001 rows with MongoDB vs. SQL Server. So he claims that MongoDB inserts 50001 rows in 30 seconds while the SQL Server one takes 1.5 minutes. Okay so I looked at this SQL Script and can make 2 improvements

First create this table

  1. CREATE TABLE MongoCompare
  2.     (guid UNIQUEIDENTIFIER
  3.     ,VALUE INT
  4.     )
  5. GO

Here is the script he used.

  1. DECLARE @id INT = 1
  2. WHILE (@id < 500001)
  3. BEGIN
  4.     INSERT INTO MongoCompare VALUES (newid(), @id)
  5.     SET @id+=1
  6. END
  7. GO

Now if I was to write that code I would write it with an explicit transaction and I would also use nocount on. So If we do this

  1. SET NOCOUNT ON
  2. BEGIN TRAN
  3. DECLARE @id INT = 1
  4. WHILE (@id < 500001)
  5. BEGIN
  6.     INSERT INTO MongoCompare VALUES (newid(), @id)
  7.     SET @id+=1
  8. END
  9. COMMIT

SQL Server now only takes 6 seconds and you have one atomic block of code, either all succeeds or nothing succeeds.


posted by LifeisSimple
2010. 12. 29. 14:12 Brain Trainning/NoSQL
출처 : http://www.mongodb.org

MongoDB, CouchDB, MySQL Compare Grid

pending...

 CouchDB 
MongoDB 
MySQL 
Data Model 
Document-Oriented (JSON
Document-Oriented (BSON
Relational 
Data Types 
string,number,boolean,array,object string, int, double, boolean, date, bytearray, object, array, others 
link
Large Objects (Files) 
Yes (attachments) 
Yes (GridFS
blobs?
Horizontal partitioning scheme 
CouchDB Lounge 
Auto-sharding (v1.6)
Replication 
Master-master (with developer supplied conflict resolution) 
Master-slave (and "replica sets")
Master-slave
Object(row) Storage 
One large repository 
Collection based 
Table based 
Query Method 
Map/reduce of javascript functions to lazily build an index per query 
Dynamic; object-based query language 
Dynamic; SQL 
Secondary Indexes 
Yes Yes Yes
Atomicity Single document 
Single document 
Yes - advanced 
Interface 
REST 
Native drivers ; REST add-on 
Native drivers 
Server-side batch data manipulation 
? Map/Reduce, server-side javascript 
Yes (SQL) 
Written in 
Erlang 
C++ C++ 
Concurrency Control MVCC Update in Place  
Geospatial Indexes 
GeoCouch 
Yes. (As of June 2010, coordinate system is cartesian. Spherical coming soon.)
Distributed Consistency Model Eventually consistent (master-master replication with versioning and version reconciliation) Strong consistency.  Eventually consistent reads from secondaries are available. 
Strong consistency.  Eventually consistent reads from secondaries are available.

See Also

posted by LifeisSimple
prev 1 2 next