I am trying to migrate my chat application from Firestore to DynamoDB.
Currently I have 2 collections in firebase: Rooms
and Users
.
Users
collection have all roomsIds the user is part of.
Rooms
collection have some meta data such as name, icon etc. along with Messages
sub-collection. Messages
sub-collection have the entire payload related to a message.
I am confused when designing my Dynamo DB ERD for the same. I have developed the following ERD along with access patters listed, but I am unable to figure out the PK, SK and Secondary index if needed.
Update 06/14/2021: I have managed to have a following design based on the answers and help I received which I think will support all my access patters.
One major query I want to run is to fetch all room's config items by userid, I am not sure if I will be able to fetch that in a single query. Right now the easy solution is to fetch all rooms of a user then fetch all config(SK) for all the fetched rooms, which I think is not a good solution.
Supported access patters:
- Get All Users in a room (PK=
ROOM#rid
&& SK=Begins_with(USER#)
) - Get Config of a single room (PK=
ROOM#rid
&& SK=CONFIG
) - Get Messages of a single room (PK=
ROOM#rid
&& SK=Begins_with( MESSAGE#)
)
Supported access patters:
- Get all rooms of a user (PK=
USER#uid
&& SK=Begins_with(ROOM#)
)