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:
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.