Amazon Dynamo DB - Issue in creating table in local database

1.7k views Asked by At

I am using local Amazon Dynamo DB and trying to create a table as; Id | StartPoint1 | EndPoint 1 | StartPoint2 | EndPoint2 | Speed | Distance

I tried using CreateTable() function but finding it difficult to create one. I am making use of .Net API.

Can anyone please help me out in getting this.

Sample code I tried was;

var response = client.CreateTable(new CreateTableRequest
      {
        TableName = tableName,
        AttributeDefinitions = new List<AttributeDefinition>()
        {
          new AttributeDefinition
          {
            AttributeName = "Id",
            AttributeType = "S"
          },
          new AttributeDefinition
          {
            AttributeName = "ReplyDateTime",
            AttributeType = "S"
          }
        },
        KeySchema = new List<KeySchemaElement>()
        {
          new KeySchemaElement()
          {
            AttributeName = "Id",
            KeyType = "HASH"
          },
          new KeySchemaElement()
          {
            AttributeName = "ReplyDateTime",
            KeyType = "RANGE"
          }
        },
        ProvisionedThroughput = new ProvisionedThroughput
        {
          ReadCapacityUnits = 10,
          WriteCapacityUnits = 5
        }
      });

For 2 columns it is working fine. For more than 2 columns, how to achieve this ?

Thanks and Regards, Vijay

2

There are 2 answers

0
Sony Kadavan On

I haven't used from C#, but seen that some APIs fail on local because you are accessing a new feature and using an older package of Dynamo DB. (One example is GSI, which is just couple of months old). This page always hosts the latest: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.DynamoDBLocal.html (Earlier there was a place on the doc page, which by mistake kept hosting an older one)

0
user3303254 On

The only attributes that you define when you create the table are the hash and (optionally) the range. This is not a relational database where each row necessarily has the same attributes.