Archive for March, 2016

DynamoDB – The beginning

22 Mar

A tale of my perilous journey into the world of Amazon’s DynamoDB…

Amazon DynamoDB is a fully managed NoSQL database service with strong consistency and predictable performance that shields users from the complexities of manual setup. You never have to worry about the maintenance or administrative burdens of operating and scaling a distributed database. You don’t have to worry about hardware provisioning, setup or configuration, data replication, software patching or cluster scaling.  With DynamoDB you can create tables that can store and retrieve any amount of data and serve any level of request traffic.

Whether or not you’ve actually used a NoSQL data store yourself, it’s probably a good idea to make sure you fully understand the key design differences between NoSQL (including Amazon DynamoDB) and the more traditional relational database (or “SQL”) systems like MySQL.

First of all, NoSQL does not stand for “Not SQL“, but “Not Only SQL“. The two are not opposites, but complementary. NoSQL designs deliver faster data operations and can seem more intuitive, while not necessarily adhering to the ACID (atomicity, consistency, isolation, and durability) properties of a relational database.

There are many well-known NoSQL databases available, including MongoDB, Cassandra, HBase, Redis, Amazon DynamoDB, and Riak. Each of those was built for a specific range of uses and will therefore offer different features. We could group those databases into columnar (Cassandra, HBase), key-value store (DynamoDB, Riak), document-store (MongoDB, CouchDB), and graph (Neo4j, OrientDB) categories.

Example 1:

Suppose you need to organize your music library. You can create a table from the DynamoDB console to store information about your songs to enable fast searches.

  1. Start by navigating to the AWS console
  2. Click on the DynamoDB icon and select ‘create table’
  3. In the ‘Table name’ field type “Music”
  4. The partition key is used to spread data across partitions for scalability; it is important to choose an attribute with a wide range of values and that is likely to have evenly distributed access patterns.  For example, if you have music from many artists you could use the Artists’ names as your partition key. So type “Artist” in the Partition key field. Since each artist may write many songs, you can enable easy sorting with a sort key. Check the “Add sort key” box and type “SongTitle” in the sort key field.
  5. Click create.
  6. Amazon DynamoDB immediately creates the music table, it takes several seconds to complete. The Music table is now ready for use.
  7. Now you can add data to the Music table. In the Amazon DynamoDB console, click the tables tab and then select the Music table and click the items tab
  8. Under the items tab click on ‘create item’  and the data entry window opens up
  9. In the data entry window, type the following, for the artist attribute put in “No One You Know”
  10. For the SongTitle attribute put in “Call Me Today”
  11. Click Save
  12. Now you can repeat this process to add a few more items to your table.

Let’s query the table for the information.

  1. By default the console shows all of the items in the Music Table. Click on the blue drop down just below the list of items
  2. In the drop down on the left select ‘query’
  3. You can use the console to query the music table in various ways
    1. For the first query, in the artist field type “No One You Know” and click on ‘Start search’
      1. All songs by ‘No One You Know” are displayed
    2. In the artist field type “The acme band” and click on Start Search
      1. All songs performed by the Acme band are displayed.
    3. In the artist field type “The acme band” in the song title field select “Begins with” from the dropdown.
    4. Type “S” and click on start search
    5. Only songs beginning with S* performed by the Acme band is displayed


Deon's Playground

Placing whatever interests me and more