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