CouchDB and Data Flow Learning

         CouchDB is a no-SQL database, which is significantly different with traditional relational database. CouchDB has no structure and everything is stored as a document, and accessed by key-value. MediaGrid uses CouchDB to store its data, because it’s easy to use.

         To access Futon, a couchdb’s util, just open 127.0.0.1:5984/_utils in browser where we can log in and manage our databases on web.

Using curl to manage CouchDB.

To check if CouchDB is running, using command:

Curl http://127.0.0.1:5984/

Where database version is returned.

To get a list of all databases, using command:

Curl -X GET http://127.0.0.1:5984/_all_dbs

To create a database, using command:

Curl -X PUT http://127.0.0.1:5984/mytest

If you’re not an admin, then specify your username and password in URL like this:

Curl -X PUT http://username:password@127.0.0.1:5984/mytest

Then {“ok”:true} should be returned.

To delete our database, using command:

Curl -X DELETE http://username:password@127.0.0.1:5984/mytest

To get a UUID, using command:

curl -X GET http://127.0.0.1:5984/_uuids

To create a document, using command:

Curl -X PUT http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af -d ‘{“title”:”There is Nothing Left to Lose”,”artist”:”Foo Fighters”}’

         And besides ‘title’, ’artist’, there two other fields _id and _rev. If you want to update or delete a document, _id and _rev should always be provided, in case you delete or update some document accidently.

        For data flow part, my mentor Dan is so helpful and amazing! while I asked him this, he draw the data flow with high efficiency and in very details as followed:

Here is the data flow diagram for the files page:
https://github.com/dismantl/MediaGrid/wiki/Files-sharing-data-flow-diagram

Here is a data flow diagram for the chat program:
https://github.com/dismantl/MediaGrid/wiki/Chat-program-data-flow-diagram

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s