Reputation: 20882
From reading on AWS it appears the DynamoDB UpdateItem is able to add an attribute to an existing item.
So for example if I have a item - primary key: UserID and this had a few attributes like member: 1 member: 2 member: 3
could I add member: 4?
* does the key member of the attribute need to be unique? if so is there a way to make this unique when the contents of the item is just a list of members numbers (their friends on the system)?
thx
Upvotes: 0
Views: 2828
Reputation: 21
In Dynamodb , Primary Key is named as "Hash Key". This is unique. We have to define while creating a table, what are the Hash Key (Only One). Say in this case
Hash Key is UserID. The advantage of Dynamodb is that we can add any number of attributes to the existing attributes. Example for UserId 1 we have member1 member2 member3 Then for user ID 2 we can have member, member2 ,member3, member4,.... We dont need to create a new column or attribute at the time of creating the table in Dynamo-db for the attributes to be updated.
Upvotes: 1
Reputation: 81
You can add new attributes as much as you like.
You should prefer use "Number Set" attr type to store friend member ids rather than adding new attr for each friend.
But don't forget the limitation
There is no explicit limitation on the number of attributes associated with an individual item, but the aggregate size of an item, including all the attribute names and attribute values, is 64KB.
Upvotes: 1
Reputation: 12901
Yes, DynamoDB supports String, Number and Binary set as an attribute.
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html#DataModelDataTypes:
String, Number, and Binary Sets
Amazon DynamoDB also supports Number Sets, String Sets and Binary Sets. Multi-valued attributes such as Authors attribute in a book item and Color attribute of a product item are examples of string set type attributes. Note that, because it is a set, the values in the set must be unique. Attribute sets are not ordered; the order of the values returned in a set is not preserved. Note that Amazon DynamoDB does not support empty sets.
Upvotes: 1