rethinkdb

9
RethinkDB Not Only Sql Presentation Zico Abhi Dey University Of Goettingen

Upload: abhi-dey

Post on 13-Aug-2015

24 views

Category:

Technology


0 download

TRANSCRIPT

RethinkDB

Not Only Sql Presentation

Zico Abhi DeyUniversity Of Goettingen

A Brief Overview

RethinkDB is

first open-source, scalable JSON database built for the realtime web.

Different from traditional databases. Instead of polling for changes, RethinkDB allows continuously push updated query results in realtime.

Official support for Ubuntu, OS X, CentOS and Debian.

How to Install:: On OS x Using Python

Server Install: Download package and simple click to

install.

Client Server: Simple Terminal Command.

$ sudo pip install rethinkdb

Access:

Start Server from terminal with $ rethinkdb

From Browser 127.0.0.1:8080 OR localhost:8080

Data manipulation

Database Creation

From GUI.

Or

From Python Shell: r.db_create(“library”).run()

Table Creation

From GUI.

Or

From Python Shell: r.db(“library”).table_create(“Book”).run()

Insert Data :: From Python ShellBook.insert({ "BookID":"123", "Author": "Date", "Title":"Introduction to DBS"}, { "BookID": "234", "Author":"Jones", "Title": "Algorithms"}, { "BookID": "345", "Author": "Kings", "Title": "Operating Systems"}).run()

Delete Data:: From Python Shellr.table(“Book”).filter(r.row[“Author”] == “Kings”).delete().run()

Programmatic access

officially support for client drivers javascript, ruby and

python. You can run queries from the command shell.

Query a print r.table('Book').pluck('Title').run() Query b print r.table('Book').inner_join(r.table('BookLending'), lambda x ,y: x["BookID"] == y["BookID"]).zip().run() Query c print r.table('Book').inner_join(r.table('BookLending'), lambda x ,y: x["BookID"] == y["BookID"]).zip().filter(r.row["ReturnDate"] < '27-10-2012').run() Query d print r.table('Book').inner_join(r.table('BookLending'), lambda x ,y: x["BookID"] == y["BookID"]).zip().inner_join(r.table('Reader'), lambda x ,y: x["ReaderID"] == y["ReaderID"]).zip().filter(r.row["Name"]=='Peter').run()

Declarative query language

Has its own declarative query language Reql. Reql queries using Data explorer of RethinkDB.

Query ar.table('Book').pluck('Title')

Query b r.table('Book').innerJoin(r.table('BookLending'), function(marvelRow, dcRow) { return marvelRow('BookID').eq(dcRow('BookID'))}).zip()

Query c r.table('Book').innerJoin(r.table('BookLending'), function(marvelRow, dcRow) { return marvelRow('BookID').eq(dcRow('BookID')) }).zip().filter(r.row("ReturnDate").lt('29-10-2012'))

Query d r.table('Book').innerJoin(r.table('BookLending'), function(marvelRow, dcRow) { return marvelRow('BookID').eq(dcRow('BookID')) }).zip().innerJoin(r.table('Reader'), function(marvelRow, dcRow) { return marvelRow('ReaderID').eq(dcRow('ReaderID')) }).zip().filter(r.row("Name").eq('Peter'))

HTTP-based access

r.http command for accessing external APIs directly from

the database.

REST-based access

Has not been introduced yet.

Support for transactions

Yes. Multiple operations can be performed in a single update operation

Support for indexing

Simple indexes: based on the value of a single field.

Compound indexes: based on multiple fields.

Multi indexes: based on arrays of values.

Aggregation

Yes the system supports aggregation operations like

SUM, COUNT, MAX

Query e:: from Python Shell

print r.table('BookLending').inner_join(r.table('Reader'), lambda x ,y: x["ReaderID"] == y["ReaderID"]).zip().filter(r.row["Name"] == 'Laura').count().run()

Query e:: from Data Explorer

r.table('BookLending').innerJoin(r.table('Reader'), function(marvelRow, dcRow) { return marvelRow('ReaderID').eq(dcRow('ReaderID')) }).zip().filter(r.row("Name").eq('Laura')).count()

RethinkDB as a distributed database system?

Yes it is possible to attach multiple machine to the cluster

in RethinkDB.

RethinkDB support autosharding?

No. Manual Shard only using GUI.

RethinkDB support replication?

Yes support multi-master replication. RethinkDB has

advantage in failover.

Replication can be performed via GUI. OR using Reql

queries.

Thank You

Any Questions?