Creating a setup table in a NoSQL Database

Viewed 85

I have an application that consumes all of its data from a DynamoDB table. I use the single table architecture, so there is one and only table for all parts of my application. I just store the data according to my access patterns;

PK: COMPANY#1318723
SK: EMPLOYEE#31931823

But besides these flying data, I want to store static and read-only data in my database as well, for example, storing country and city names, constant values to share with other applications, static strings to not hard-code in my application, and many other things. I am coming from an RDBS background, and we used to create setup tables to store that kind of data. My setup tables used to look like this;

TABLE_COUNTRY_NAMES

Id     Name          Code       DialCode
1      Germany       de         49
2      Turkey        tr         90
.      .             .          .
.      .             .          .
.      .             .          .

And to consume it, I used to use enumerations in my application code such as;

{
 1: "GERMANY",
 2: "TURKEY",
 .
 .
 .
}

It made my code much cleaner and easy to understand. It was also a better practice to store this data in the database rather than hard-code it in my application so that I could use it in other applications which work together with my main application, share the static values across apps safely, and apply changes without going and editing the data in each application's source code. Now, when I want to bring that approach to the DynamoDB side with a single table design, I want to be sure about what would be the best practice.

  1. I can create another DynamoDB table, again with a single table design, and store all of my static values into that table.
  2. I can store all of the static values inside the same table with my main application, just setting the correct naming for Primary and Secondary Key values. But it will make my single table much more dirtier.
  3. I can use an RDBS such as PostgreSQL to store and distribute those static values into separate setup tables such as TABLE_SETUP_COUNTRY_NAMES,TABLE_SETUP_PROMPT_MESSAGES, TABLE_SETUP_CONSTANT_VALUES, and etc.

I would like to hear your ideas about what would be the best practice in this scenario and how do you usually implement it in your applications.

Thanks.

1 Answers

As you are going to use that static data in your different applications so in my point of view you can create another DynamoDB table, again with a single table design, and store all of your static values into that table.

It will be easier for your to maintain those static data and access those data using that DynamoDB single table.

Related