cdub
cdub

Reputation: 25711

Creating a unique Primary Key for use in AWS DynamoDB

I want to use an 8 char alphanumeric objectId (like Parse did) as my primary key. Does AWS DynamoDB have a function to create this or do I need to create it somehow in my iOS app and submit it up to the DB?

Learning how DynamoDB works as I came from RDB background.

Also is it better to have one big table like say if I had Users and Photos, do I put that in the same table as Users take Photos? Or is there a way to link somehow?

Upvotes: 1

Views: 2628

Answers (2)

aydow
aydow

Reputation: 3801

DynamoDB recommends the use of single table design. The purpose of this is to eliminate joins which are expensive so it can just focus on fetching the data. There are drawbacks to this and it's confusing as hell coming from a RDBMS foundation but you do get great response times when you're dealing with a mammoth dataset.

You could create a table of users and photos but you would have to create the join functionality manually. An example of properly leveraging DynamoDB, is to a single table of user photos (assuming that's your only data) where the primary key is a composite of a user ID and a photo URL.

Upvotes: 0

Jerome Anthony
Jerome Anthony

Reputation: 8021

No it doesn't. DynamoDB has very few features. You have to cook up something yourself. Read to get an idea of how to build a auto incrementing system for DynamoDB records.

Upvotes: 1

Related Questions