database - How would I design this schema in MongoDB? -
let's take example of chat room.
should create 2 collections: room
, messages
, , store room details (title, description) separately messages (body/date/author)? messages collection have field called "room" links objectid of room.
or
should create 1 collection, called room. , inside room, there array of messages?
what best practice? do?
i lean toward first choice. aside fact 16mb may small (i've seen pretty busy chat rooms in days), storing messages separately allows greater flexibility on part. room doesn't need know messages associated - create once , query messages room
id needed.
Comments
Post a Comment