Reputation: 267059
Say I have an order
table which stores orders made by users. It has the following schema:
id (string, unique primary key)
userId (string, id of the user who made the user
I'd like to add a global secondary index on the userId
column, but it will be non-unique, i.e a single user may make multiple orders, which means there might be multiple orders with the same userId
.
From reading the docs, I can't quite tell if this scenario would be ok, or if I need to add a range key to make the primary key be unique.
I'd prefer not to have to add a range key, so I can simply use the userId to get all the orders made by a particular user.
Any thoughts?
Upvotes: 3
Views: 2584
Reputation: 10056
this scenario would be ok, global secondary index can be non unique. the only disadvantage (that i can think about) is that if you have a 'mega' user, with multiple orders (on write), it can accuse throughput capacity errors..
a good reference is here:
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GuidelinesForTables.html
Upvotes: 2