I am coming from an Android Application Development background. I am exploring DynamoDB and I've written a Kotlin server and linked it with DynamoDB. While I have successfully made connection, table, Partition Keys and Sort Keys, I'm having some trouble with Global Secondary Index.
I'm trying to build a pagination API, API needs support following params:
query by
title, release date, genres, min rating, max rating, tags.
I also want to sort by,
release date, rating.
Since in my assets table imdb_id
is set as Partition Key. And I'm using Sort Key for storing DETAILS
(contains all essential info (non-key) such as title, release date, rating, description, etc.) and RECOMMENDATION
. SK in this format because, I needed a way to make lists of recommended movies for each movie, I could have supplied a field with the json of array objects as String or String Array, but since I am storing the movies' detail info anyways (and I'd want them to be available in the database as queryable items), it made much more sense to have them as separate records. So, I stored the original movie as a DETAILS
record, I stored each recommended movie as a separate RECOMMENDATION#<imdb_id>
record. Recommendations only contained the imdb_id
of the recommended movie (which can be used to fetch DETAILS
of the recommendation). And then finally I stored each of the recommended movie as a DETAILS
record.
This way, I was able to keep a record of all of the recommendations against all movies while also storing the DETAILS
info of those recommended movies too. I hope that makes sens3!