Skip to main content

Managing Documents in Java Web Application using NoSQL Database and HTTP APIs

Over the years, the method to store documents was to keep them in the database with a blob or to store them on the file system. Times are changing and today you can attach actual documents to the database, where the database itself takes care of revisions, eliminating the need for data conversion, i.e. no data types/formats etc.

NoSQL Databases

A NoSQL (originally referring to “non SQL” or “non-relational”) database provides a mechanism for storage and retrieval of data that is modeled differently from the tabular relations used in relational databases.

In the past decade or so, relational database management systems have been the choice of many developers and system administrators for a variety of applications and reasons. Despite not being exactly flexible, the powerful nature of many RDBMS allows complex database set-ups to be created, queried and used. This is more than enough for most requirements.

The term “NoSQL” was coined over a decade ago, funnily enough as a name to yet-another relational database. However, this database had a different idea behind it: eliminating the use of the standardized SQL. Fast forward a few years, and various other non-relational databases became NoSQL databases.

By design, NoSQL databases and management systems are relation-less (or schema-less). They are not based on a single model (e.g. relational model of RDBMSs) and each database, depending on their target-functionality, adopts a different one.

Some of the popular NoSQL databases currently available are:

  • Cassandra
  • MongoDB
  • CouchDB
  • Redis
  • HBase
  • Neo4j
  • Hypertable
  • ElasticSearch

When To Use NoSQL Databases

  • Size: If you are working with large sets of data, constant and consistent scaling is easier to achieve with many of the DBMS from NoSQL family.
  • Speed: NoSQL databases are usually faster when it comes to `writes’. Reads can also be very fast depending on the type of NoSQL database and data being queried.
  • Schema-free design: Relational DBMSs require structure from the beginning. NoSQL solutions offer a large amount of flexibility.
  • Automated (or easy) replications / scaling: NoSQL databases are growing rapidly and they are being actively built today.  Vendors are trying to tackle common issues and one of them clearly is replication and scaling. Unlike RDBMSs, NoSQL solutions can easily scale and work with (in) clusters.

Types of NoSQL databases

There are 4 basic types of NoSQL databases:

  1. Key-Value Store – It has a Big Hash Table of keys & values {Example- Riak}
  2. Document-based Store– It stores documents made up of tagged elements. {Example- CouchDB}
  3. Column-based Store– Each storage block contains data from only one column, {Example- Cassandra, HBase}
  4. Graph-based-A network database that uses edges and nodes to represent and store data. {Example- Neo4J}

…to be continued.  Don’t miss my next blog on CouchDB

Sangamaeswaran T

Sangamaeswaran T

Sangamaeswaran works as Technical Leader with Trigent Software. He has more than ten years of experience in Java/J2ee web development and strong expertise in SAAS applications, CXF, RESTful Web Services, OFBiz, Spring, DOJO and CouchDB.