Simple DB: is it really simple??

Simple DB: is it really simple??

For one of my projects I recently used Amazon Simple DB as database. After doing some intensive work it prompted me to write something about my experiences with this. For the beginners, Simple DB is a database service provided by Amazon Web Services. They have their server machines in various regions (in US, Europe, Asia Pacific and South America) where they store data. If you want to use it, you need to create account with Amazon Web Services (AWS) and you need to pay as per use of the data. So if you use Simple DB then you don’t need to create database on your local machine. Amazon provides SDK for Java, .NET, PHP, android etc developers to interact with simple DB. Apart from that it also provides REST APIs for its various operations which return you XML responses. In order to use simple db, you need to register on AWS site and get a Access Key ID and Secret. These are required in Simple DB API calls. Since I am too lazy to write complete description and anyways AWS doesn’t pay me to write this article so not going to write all its features J , for detailed feature list you can visit at : http://aws.amazon.com/simpledb/ . Right now I just want to write an overview of using simple db and evaluate it as per my experiences with it.

So let me give answers of below questions if anyone has for simple DB:

Q. Is it RDBMS like oracle/Mysql etc?

Ans.: No, its not. It has different mechanism to store and retrieve data which we will see later in this article.

Q. How does it stores data and what are major terms related to simple db?

Ans.: Simple DB has concepts of domains, its similar to the tables on oracle or any other relational DBMS. In each domain there is an Item which should be unique (which is equivalent to the primary key in Oracle etc). Each item contains a set of attributes (equivalent to column in RDBMS) . Every attribute will have a name and a value to store.

Q. What are major operations supported in simple db?

Ans.: Below is the list of major operations supported by simple db:

CreateDomain: The CreateDomain operation creates a new domain. The domain name must be unique among the domains associated for the given Access Key ID.

ListDomains: The ListDomains operation lists all domains associated with the Access Key ID.

DomainMetadata: Returns information about the domain, including when the domain was created, the number of items and attributes, and the size of attribute names and values. you need to paas domain name in request parameter.

DeleteDomain: Deletes the domain name specified in request parameter. Also deletes all the items and attributes inside that domain.

PutAttributes: The PutAttributes operation creates or replaces attributes in an item. You specify new attributes using a combination of the Attribute.X.Name and Attribute.X.Value parameters. Attribute name cannot be empty while attribute value can be.

BatchPutAttributes: With the BatchPutAttributes operation, you can perform multiple PutAttribute operations( as of now for 25 items) in a single call. Saves time.

GetAttributes: Returns all of the attributes associated with the item. Domain name and item name is passed in the request parameter.

DeleteAttributes: Deletes one or more attributes associated with the item. If all attributes of an item are deleted, the item is deleted.

BatchDeleteAttributes: Performs multiple DeleteAttributes operations(as of now for upto 25 items) in a single call , which reduces round trips and latencies.

Select: The Select operation returns a set of Attributes for ItemNames that match the select expression. Select is similar to the standard SQL SELECT statement.

Why and When to use simple DB ?

1.       No Space problem in local machine: Since data is stored in remote machines of amazon (or in other words in cloud), so you don’t have to worry about storing data locally. Also, due to high availability of amazon servers connectivity is not usually a problem. But as a developer you need to make sure that your internet connection is working fine or else it will be a problem.

2.       API support: Simple DB provides vast set of APIs and libraries in Java, .NET, PHP and other languages. For each major language they have SDK to perform simple db operations like create and delete domains, insert, update and delete items with attributes and select statements to get values. For more info on simple db libraries and codes for different platforms, please refer below link:

http://aws.amazon.com/code

You can even set the region of servers where you want to store and get data from. It helps in performance as if your servers and in Asia it’s better to use Amazon’s servers in Asia to reduce latency and get responses early.

3.       Scalable and Secure: Amazon has pay as per your use policy. So if u want to store more data ( and obviously have good money to pay for that ) then you can have as many number of domains and attributes as well. But let me be clear, if your data and their relationships are complex then please don’t go for simple db. By the way if data is a bit large but you don’t need too many domains then you can think of simple db. Also, the data transfer between your local machine and simple db happens using HTTPS so it provides security for the same.

Here I have tried to give a brief into and features of simple db. But hang on!! not bed of roses and it comes up with many restrictions and drawbacks. While using simple db, I also had to spend many sleepless nights due to shortcomings of it and had to do many workarounds. Listing those here will make this article too long as well as boring so have decided to dedicate one complete separate article for that purpose.

7 Comments

  1. Naved says:

    Nice article, concise and immaculate.

  2. Rashmirathi says:

    Good informative post.

    I would look forward to try Simple-DB when I get suitable work-case.

    Thanks for the article.

  3. priyanka says:

    its really good and useful information

  4. priyanka says:

    its really good and useful information :)

  5. Tarun says:

    No offense to the article, it is indeed good knowledge sharing one, but I think as the name says, it can only store Simple data….Still needs to improve a lot in terms of Functions/Proc/Triggers/Views.

    Thanks!

    1. Manish says:

      Hi Tarun,
      Yes there are many restrictions related to data storage and transfer in simpleDB . Here is second part of my article which deals with restrictions and drawbacks of SimpleDB : http://blog.raremile.com/2012/05/simple-db-restrictions-and-drawbacks/ . The thing is NoSql databases like SimpleDb are meant to be used in some specific scenarios and they can never replace the traditional RDBMS.

  6. Nishit says:

    A nice read pointing out why not to use SimpleDB or any NoSQL databases for that matter. I think that the NoSQL databases are hype-driven to a lot of extent (even though they do give some pretty good features). It is very important to know when not to use NoSQL and not to go ‘with the flow’. I feel the first thing that one should do is try and not compare it with RDBMS. RDBMS is good in what it does by providing relations among tables, maintaining integrity and providing countless ways to get data in almost any format. The general aim in RDBMS is to normalize the data. But in NoSQL is all you need to think is how to denormalize the data. This is one of the many reasons why comparing NoSQL with RDBMS is futile and why NoSQL should not be an alternative to RDBMS. NoSQL should be used where high write operations are needed and consistency can take a back seat. Another place where you can NoSQL is where the data that you are storing has a dynamic ‘schema’. And it serves very well in that.
    All in all, NoSQL is a very good option, but not to replace or overcome RDBMS and its shortcomings, but to store your unstructured data.

Leave a Comment

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

*
= 5 + 6