mercredi 23 octobre 2019

convert mysql database to dynamodb model

I'm new to dynamoDb and I'm trying to get the hang of it but I'm not getting how to store 'master' table details in single table dynamoDb.

For example, take this movie database.

category table(refer this as a master table)
+----+----------+
| id | category |  
+----+----------+
| 1  | thriller | 
+----+----------+
| 2  | horror   | 
+----+----------+
| 3  | romantic |
+----+----------+

movie table (category_id is FK)
+----+-----------+-------------+
| id | name      | category_id |  
+----+-----------+-------------+
| 1  | gone girl | 1           | 
+----+-----------+-------------+
| 2  | get out   | 1           |
+----+-----------+-------------+
| 3  | seven     | 1           |
+----+-----------+-------------+
| 4  | us        | 2           | 
+----+-----------+-------------+
| 5  | it        | 2           |
+----+-----------+-------------+

how to model this in dynamoDb and what would be the query if I want to get all the possible categories. Consider there are few more Fk's in the movie table.

Aucun commentaire:

Enregistrer un commentaire