Book Image

Getting Started with RethinkDB

By : Gianluca Tiepolo
Book Image

Getting Started with RethinkDB

By: Gianluca Tiepolo

Overview of this book

RethinkDB is a high-performance document-oriented database with a unique set of features. This increasingly popular NoSQL database is used to develop real-time web applications and, together with Node.js, it can be used to easily deploy them to the cloud with very little difficulty. Getting Started with RethinkDB is designed to get you working with RethinkDB as quickly as possible. Starting with the installation and configuration process, you will learn how to start importing data into the database and run simple queries using the intuitive ReQL query language. After successfully running a few simple queries, you will be introduced to other topics such as clustering and sharding. You will get to know how to set up a cluster of RethinkDB nodes and spread database load across multiple machines. We will then move on to advanced queries and optimization techniques. You will discover how to work with RethinkDB from a Node.js environment and find out all about deployment techniques. Finally, we’ll finish by working on a fully-fledged example that uses the Node.js framework and advanced features such as Changefeeds to develop a real-time web application.
Table of Contents (15 chapters)
Getting Started with RethinkDB
Credits
About the Author
Acknowledgement
About the Reviewer
www.PacktPub.com
Preface
Index

Preface

Databases are all around us. In the modern web, almost every website that we visit and the web-based applications that we use have a database system working behind the frontend. Web developers are constantly looking for new database solutions that adapt to the modern web, allowing them to store data in a simpler manner.

RethinkDB is both the simplest and the most powerful document database technology available across Linux and OS X platforms. Based on robust and feature-rich software, RethinkDB provides a bunch of features that can be used to develop some real-time web applications that can be scaled incredibly easily. RethinkDB is also open source, so the source code is freely downloadable from the database GitHub repository.

This book provides an introduction to RethinkDB. The following chapters will give you some understanding and coding tips to install and configure the database and start developing web applications with RethinkDB in no time.

What this book covers

Chapter 1, Introducing RethinkDB, explains how to download and install RethinkDB on both Linux and OS X.

Chapter 2, The ReQL Query Language, explains the basics of RethinkDB's query language and how to use it to run simple queries on the database.

Chapter 3, Clustering, Sharding, and Replication, explores the different techniques you can use to scale RethinkDB.

Chapter 4, Performance Tuning and Advanced Queries, gives out best practices to obtain optimal performance and explores more advanced queries.

Chapter 5, Programming RethinkDB in Node.js, explains how to interact with the database using the Node.js programming language.

Chapter 6, RethinkDB Administration and Deployment, teaches you how to maintain your RethinkDB database instance and how to deploy it to the cloud.

Chapter 7, Developing Real-Time Web Applications, explores how to develop a full-fledged Node.js web application based on RethinkDB.

What you need for this book

To get the most out of this book, you'll need a computer or server running OS X or any other Linux distribution.

You will also need an Internet connection and administration privileges to download and install the database.

Finally, you will need a text editor to edit configuration files and write code. There are many freely available editors, such as Nano, Emacs, or Gedit. Choose the one you prefer!

Who this book is for

This book is targeted at anyone interested in learning how to get started with the RethinkDB database. No prior database programming experience is required, however you should be comfortable with installing software, editing configuration files, and using the terminal or commandline. A basic knowledge of Node.js is recommended, but not required.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The default RethinkDB package includes various control scripts including the init script /etc/init.d/rethinkdb."

A block of code is set as follows:

r.db("test").table("people").indexStatus("name_and_age")
{
  "function": <binary, 125 bytes, "24 72 65 71 6c 5f..."> ,
  "geo": false ,
  "index": "name_and_age" ,
  "multi": false ,
  "outdated": false ,
  "ready": true
}

Any command-line input or output is written as follows:

rethinkdb import -f data.json --table test.people
sudo pip install rethinkdb

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "You can do this from the Data Explorer section of the web interface by clicking on the Options icon and checking the query profiler checkbox, as you can see from the following screenshot."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/GettingStartedwithRethinkDB_ColorImages.pdf

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.