Posts Tagged 'DynamoDB'

Creating Items and Exploring Tables in Amazon DynamoDB

Having earlier created some tables for our application we will now quickly see how to store some items.

Using the AWS SDK it could be done programmatically very simply as follows:

Figure 1. Code to populate the Players Table with sample Items.

A couple points to reinforced:

  • Not all items need to have the same set of attributes
  • Attributes can be single or multi-valued

Tables can be explored interactively using the AWS Explorer from within Visual Studio.

Figure 2. Explore the Players Table using AWS Explorer from within Visual Studio

Note that item order is not preserved nor is order of list entries in multi-valued attributes.

Alternatively, as of May 22, 2012 you can also use the AWS Management Console to explore, monitor and configure DynamoDB tables.

Okay, cool. So now what? Well we could (and we will) consider ways to query the data. We could also talk about the usual CRUD stuff but we are not going to do that right now. Instead our next game will be to wrap up an interface to our storage that can be implemented as a Web Service. This will allow us to further abstract from DynamoDB and define our interface in terms of objects in our problem domain. Under the covers we will we using DynamoDB but we will have isolated specific code so that if, in the future, we wanted to use something else for storage (SimpleDB, Azure Tables or even a relational database) it will be relatively straight forward to make the necessary changes.

That will be the subject of my next post. In the meantime you might want to check out some of the supplementary course materials available for Learning Tree’s Amazon Web Services course. While some of the programming references there are for Java and not C# you will find that the concepts are equally relevant.

Kevin Kell

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

Amazon DynamoDB Ups the Ante for NoSQL Database Service

This past week I watched with great interest as Amazon CTO Werner Vogels announced the launch of Amazon’s DynamoDB service. I feel that rather than trying to say something pithy I will just recommend that you check it out for yourselves.

DynamoDB is a NoSQL database service that is, in my opinion, head and shoulders above what Amazon previously offered with SimpleDB.

DynamoDB removes almost all of the administrative burden associated with provisioning a database for an application. Developers can simply create a database and assume it will be available to store and retrieve any amount of data and serve any level of traffic that may materialize. DynamoDB handles all the load balancing for you transparently behind the scenes.

Unlike some NoSQL databases, DynamoDB gives the developer the choice between strong consistency or eventual consistency on every database transaction. This allows for great control over what happens when data is read or written. Also, DynamoDB has built-in fault tolerance to automatically and synchronously replicate data across multiple Availability Zones.

DynamoDB also integrates with Amazon Elastic Map Reduce. For example it is pretty straightforward to use EMR to analyze data stored in DynamoDB and to archive results in Amazon S3.

DynamoDB is an example of another storage option offered in the cloud. Developers should consider this option for any future development projects they may have.

Kevin Kell


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: