Book Image

RavenDB 2.x Beginner's Guide

By : Khaled Tannir
Book Image

RavenDB 2.x Beginner's Guide

By: Khaled Tannir

Overview of this book

RavenDB is a second generation document database written in .NET, offering a flexible data model designed to address requirements coming from real-world systems. It is different from the other document databases around, as with RavenDB you can get up and running in a few minutes, and that includes grasping all the basics. It allows you to build high-performance, low-latency applications with ease and efficiency.RavenDB 2.x Beginner's Guide introduces RavenDB concepts and teaches you everything, right from installing RavenDB, to creating documents, and querying indexes. This book will help you take advantage of powerful, document-oriented NoSQL databases and build a solid foundation on which you can create your .NET applications. This book presents RavenDB, the .NET document-oriented NoSQL database, through a series of clear and practical exercises that will help you to take advantage of this database server. The book starts off with an introduction to RavenDB and its Management Studio. You will then move ahead and learn how to quickly and efficiently build high performance, NoSQL document-oriented .NET applications using the .NET client API or the HTTP REST API. Next, Dynamic and static indexes that use map/reduce to process datasets are covered. You will then see how to create and query these indexes, with the help of detailed examples. You will also learn how to deploy your RavenDB server in a production environment and how to optimize and secure it.With numerous practical examples, RavenDB 2.x Beginner's Guide teaches you everything you need to know for building high performance .NET document-oriented NoSQL databases.
Table of Contents (21 chapters)
RavenDB 2.x Beginner's Guide
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – creating a new database and adding sample data


Currently, the server is empty and we have an empty default database named system. In order to see what the data will look like in the Document database, we are going to use the Management Studio features to create a new database and create some sample data to populate the database with these data.

Note

We assume that the RavenDB server is running and the Management Studio is open in the web browser. If not, you can refer to the previous section to launch the RavenDB server in the Console mode.

  1. Click on your web browser to activate it. The RavenDB Management Studio is open.

    Note

    On the right side of the wizard form, you can choose to activate features provided by some available bundles (the RavenDB extensions). You can choose to activate data compression or data encryption and so on. These choices are inclusive and you can activate more than one bundle.

  2. Create a new database using the wizard form and name it Sales.

  3. Click on the Tasks tab to display the tasks screen.

  4. Click on the Create Sample Data button to create the sample data.

  5. Click on the Documents tab to display the Documents screen and verify that the sample data has been added to the current database.

What just happened?

We just created a new database and populated it with sample data.

In steps 1 and 2, we created a new database named Sales using the Management Studio's Create new database wizard.

By default, RavenDB allows anonymous access only for read requests (HTTP GET), and since we are creating data, we need to specify a username and a password to generate the data. You can control this by changing the AnonymousAccess setting in the server configuration file, which requires the server restart to apply changes.

In steps 3 and 4, we generated sample data using the Management Studio features.

When we create sample data using the Create Sample Data feature of the Management Studio, the current database must be empty and there shouldn't be any documents in the database, otherwise, the data generation action will fail.

While inserting the sample data into the Sales database, the Management Studio displays the progress log. When the process is done, there are about 250 documents and four new indexes in the database.

In step 5, we opened the Documents screen and verified that the sample data has been added to the Sales database.

Shutting down the RavenDB server in the Console mode

As easy it is to launch the RavenDB server in the Console mode, it is also easy to shutdown the RavenDB server in the Console mode.

Once the Start.cmd file is executed, a new command prompt window is opened and it shows the server activity log. This RavenDB server instance would still be running until you press the q key command which will shutdown the RavenDB server and close the command prompt window.