1
votes

I have a use case where I want to create a Dynamodb Table which contains only 2 attributes - List of String (for example, Countries) and a Boolean value.

I am extracting this value for each country and implementing different logic in case of true or false.

My question is that, what is a best way (best practice) to create a dynamodb table.

I thought of few of following ways -

  1. Boolean value as a key Use boolean value as key and List as another attribute.

  2. Add a row for each country. Create a separate record with Country value as key and flag as an attribute.

  3. Use List of countries as key and boolean value as another attribute. (I don't think this can be a good choice)

What could be the best practice while designing tables like this?

Thank You,

Prasad

1

1 Answers

2
votes

From AWS DynamoDB Docs, NamingRulesDataTypes:

When you create a table or a secondary index, you must specify the names and data types of each primary key attribute (partition key and sort key). Furthermore, each primary key attribute must be defined as type string, number, or binary.

There are many options to model your table, but keep in mind you have to respect the rules cited above.

Your second case is a good one:

  1. Add a row for each country. Create a separate record with Country value as key and flag as an attribute.
  • Partition key: country - string
  • Some column you do not have to define at creation: flag - boolean