Implementing a Data Storage Tier in the Cloud Using Amazon DynamoDB

One of the most important aspects of application design is the storage tier. For many developers a relational database has traditionally been the engine of choice. While that is often a good solution, the cloud has certainly brought other options to light. NoSQL is increasingly gaining popularity as an alternative that offers internet-class scalability when the benefits and overhead associated with a relational database are neither needed nor desired.

Of course good system design would incorporate a logical model of the data anyway which would be abstracted from any particular physical storage technology. That logical model could be implemented  using a variety of products and would mitigate the risk of vendor lock in. That is not, however, a subject I am going to cover in this post. Here I am going to just move ahead with how a simple data model can be implemented using Amazon DynamoDB.

It is very easy to get started using DynamoDB. After you subscribe to the service you can use the AWS Console to provision resources. At some point, though, you will have to write some code. Amazon provides an SDK for Java, .NET and PHP. If you use the Eclipse or Visual Studio IDE there is also a plug-in toolkit which will enable you to easily create projects that use DynamoDB and will allow you to interactively create tables right from within your development environment. You can also create tables in your code.

Figure 1. Installing the AWS toolkit for Visual Studio allows access to AWS Services from within the IDE

NoSQL databases such as DynamoDB are schema-less. That means tables are defined simply in terms of a hash key and an optional range key. Tables contain items and each item has one or more attributes. Attributes are simple name-value pairs. Items in a table do not necessarily all have to have the same attributes. Tables in DynamoDB are also provisioned for a “throughput capacity” (read and write) and may be configured for alarms using CloudWatch. Relationship semantics between the tables are handled in the code. While this may seem a little strange to someone who is used to working only with relational databases it does allow for a lot of flexibility.

Figure 2. Creating a table in DynamoDB

For example the application I am building is going to be used to track golf betting games that might occur in a regular weekend choose-up. On any given Sunday’s foursome there may be one or more of these games in play. Each game has a slightly different set of rules, point count, stake and payout logic. The goal of this application is to minimize confusion when it comes time to settle up on the 19th hole!

Now, this application could become pretty complex because of all of the possible sub-games that could occur on a round. Also golf betting is usually done based on net strokes per hole which may be taken as they lay or played off the low handicap. We will leave most of these complications aside for now and start by building something simple which can be later refined. This, to me anyway, is one of the beauties of a NoSQL approach to storage.

So, to get started, let’s say at a minimum I will need to store data for each Round, the Players involved and the Games in play. I will create three tables in code as follows after downloading the AWS SDK and re-using some sample code:

Figure 3. Creating Rounds table in code. Players and Games are similar but do not require a Range Key.

Next week we will populate these tables and start using them for storage in the application.

To learn more about cloud computing with Amazon, check out Learning Tree’s course, Cloud Computing with Amazon Web Services.

Kevin Kell

1 Response to “Implementing a Data Storage Tier in the Cloud Using Amazon DynamoDB”



  1. 1 Creating Items and Exploring Tables in Amazon DynamoDB « Perspectives on Cloud Computing from Learning Tree International Trackback on May 30, 2012 at 7:55 am
Comments are currently closed.



Learning Tree Logo

Cloud Computing Training

Learning Tree offers over 210 IT training and Management courses, including Cloud Computing training.

Enter your e-mail address to follow this blog and receive notifications of new posts by e-mail.

Join 53 other followers

Follow Learning Tree on Twitter

Archives

Do you need a customized Cloud training solution delivered at your facility?

Last year Learning Tree held nearly 2,500 on-site training events worldwide. To find out more about hosting one at your location, click here for a free consultation.
Live, online training
.NET Blog

%d bloggers like this: