google cloud datastore - Modeling an invite schema with embedded collections with dynamodb or docuemntdb -
i'm investigating whether use aws dynamodb or azure documentdb or google cloud price , simplicity app , wondering best approach typical invite schema.
an invite has
- userid : key (who created invite)
- gameid : key
- invitationlist : collection of userids
the queries running are
- get invites userid == me
- get invites userid in invitationlist
in mongo, set index on embedded invitationlist, , in sql set join table of gameid , invited userids.
using dynamodb or documentdb, in 1 "table" or have set second denormalized table 1 has invited userid per row set of invitedgameids?
e.g.
a secondary table with
- inviteduserid : key
- gameids : collection
similar hslriksen's answer, if criteria met, recommend denormalize of single document. criteria are:
- the invitationlist games cannot grow unbounded.
- even if it's bounded, maximum length array fit in document , transaction limits.
however, different hslriksen, recommend example document this:
{ gameid: <some game key>, userid: <some user id>, invitationlist: [<user id 1>, <user id 2>, ...] }
you might decide use built-in id
field games in case name above wrong.
the key difference between propose , hslriksen invitationslist pure array of foreign keys. allow indexes used array_contains clause in query.
note, in documentdb, tend store entity types in same big bucket , distinguish them string type
field or better, is_my_type
boolean field.
Comments
Post a Comment