Creating a product catalog with djondb, PHP Restler and Backbone JS Part I – NoSQL Concepts

Intro

In these series of posts, we’ll create a sample application using djondb database. You’ll see how easy is to create applications using a NoSQL database, especially with djondb, compared to a relational database.

In the first part, we’ll start designing our application and understanding the architecture.

In second part, we’ll install djondb and we’ll use the djondb console.

In third part, we’ll create the REST services that provide the business logic of our sample application.

In fourth part, we’ll create the client application for the final user.

And finally, in fifth part, we’ll add a new feature from database level and see how easy is to make this kind of changes using a NoSQL approach.

So, let’s get started…

Designing the application

The application we’ll create is a simple product catalog. The user will be able to:

  1. Browse available products
  2. See product details
  3. Add a new product to the catalog

We want to use a web browser to use the application, so the client will be an HTML, CSS and JavaScript application created with Twitter Bootstrap and Backbone.js.


Here’s the final product you are building. Browse available products:

 

Product details:

 

Add a new product to the catalog:

 

This HTML client will consume PHP REST services created with PHP Restler that store and retrieve data from a djondb database.

This is the architecture diagram of the application:

 

The following image depicts the folder structure of the application:

 

All the client code is in the assets folder. And the services layer is inside the REST folder as shown in the image below:

 

Design the data model

Books have properties such as Author, ISBN and Release Date among others. In a traditional relational database model, we’ll surely create a Book table for storing books of the catalog as shown in the image below:

djondb stores data in a BSON format, in simple terms is binary representation of the JSON format. Let’s write a JSON that help us to understand the data we want to store:

     
        product: { 
          _id: 1, 
          prodtype: book, 
          name: NoSQL Distilled, 
          picture: nosql.jpg, 
          author: Martin Fowler, 
          price: $29.29, 
          releasedate: 2012/08/08, 
          isbn: 0321826620 
        } 
    

We’re not doing anything with this JSON at this moment; we only want it to understand how our data will be stored. That’s all we need for now, in the second part of these series, we’ll install djondb database.

Posted in djondb application, NoSQL Samples and tagged .
Loading Facebook Comments ...

Leave a Reply

Your email address will not be published. Required fields are marked *