title: Dynamo DB partition key design: Few distinct partition keys but always a unique sort key
body: <p>I'm new to DynamoDB and I'm struggling with designing a good partition key.
  I read that a good DynamoDB uses a partition key with almost distinct values.
  Nevertheless I wondered if I could use a DynamoDB with only ~10 (distinct) values for a partition key if I'm always able to use the sort key as a unique identifier (eq not startswith). Will I run into problems with this approach?</p>
  
  <p>My <strong>problem(s)</strong> looks like this:</p>
  
  <p>1.
  Let's say I want to <strong>visualize rooms in few houses</strong>. Every room has IoT devices that should be visible in a kind of "room map". <strong>Visualization is done and stored in a json format</strong> locally at the moment. I want to store this configuration in the DynamoDB. My <strong>partition key</strong> would be the <strong>houses</strong> and the <strong>sort key</strong> would be a prefix with roomMap_ followed by the room name (unique for a partition key of course)</p>
  
  <pre><code>| partition key | sort key            | room map json |
  |---------------|---------------------|---------------|
  |        House1 | roomMap_livingRoom1 |         {...} |
  |        House1 | roomMap_livingRoom2 |         {...} |
  |        House1 | roomMap_kitchen     |         {...} |
  |        House2 | roomMap_livingRoom1 |         {...} |
  </code></pre>
  
  <p>2.
  Now I also want to <strong>store dashboards for the IoT devices</strong> in the DynamoDB. <strong>DeviceIds are unique for a House (by design), but can be the same in other houses</strong>. E.g. a device 'fridgeSensor' could exist in more than 1 house. The dashboard configuration is also stored as json. </p>
  
  <pre><code>| partition key              | dashboard config json |
  |----------------------------|-----------------------|
  | House1::fridgeSensor       |                 {...} |
  | House1::temperatureSensor1 |                 {...} |
  | House2::fridgeSensor       |                 {...} |
  </code></pre>
  
  <hr>
  
  <p>As I read that a <strong>good DynamoDB design uses only 1 table</strong> I thought about the following tabl by using PartitionKey of the first table design and adapt the sort key:</p>
  
  <pre><code>| partition key | sort key            | room map json | dashboard config json |
  |---------------|---------------------|---------------|-----------------------|
  |        House1 | roomMap_livingRoom1 |         {...} | null            
  |        House1 | roomMap_livingRoom2 |         {...} | null
  |        House1 | roomMap_kitchen     |         {...} | null
  |        House2 | roomMap_livingRoom1 |         {...} | null
  |        House1 | device_fridgeSensor |          null | {...}
  |        House2 | device_fridgeSensor |          null | {...}
  </code></pre>
  
  <p>Now I would often read the same partition key. <strong>Is this a bad design?</strong>
  And if yes how could i do better?</p>