Database Reference
In-Depth Information
Observe the
String
range key attribute
Author#Edition
. Even if some of the items
don't have the edition included in the range key attribute, it will not create any trouble at
the DynamoDB end (but we have to take care from the application programming front).
Some of you might have thought of making the range key attribute type as
StringSet
,
but remember that hash or range key attributes cannot be a
Set
type.
There are a few things to be kept in mind before choosing the correct hash and range at-
tributes:
• Since the table is partitioned based on the hash key attribute, do not choose re-
peating attributes that will have only single-digit (very few) unique values. For
example, the
Language
attribute of our table has only three identical values.
Choosing this attribute will eat up a lot of throughput.
• Give the most restricted data type. For example, if we decide to make some num-
ber attributes as primary key attributes, then (even though
String
can also store
numbers) we must use the
Number
data type only, because the hash and ordering
logic will differ for each data type. Other advantages will be discussed in
Chapter
• Do not put too many attributes or too lengthy attributes (using delimiter as dis-
cussed formerly) into the primary key attributes, because it becomes mandatory