An Aggregate Root should always have a unique ID within the bounded context. Typically the examples one finds use a GUID for this to ensure global uniqueness.
However consider a bounded context for a Chat. In this case I deem messages and chats as their own individual aggregate roots. One may consider Message an entity of Chat, however if messages are to grow without bounds, this is infeasible.
Therefore a Message would hold the reference to the Chat to which it belongs, by ID. In this case I would need a large enough message Id to ensure that it is unique w.r.t. all other messages independent of Chat.
I am wondering if it is bad practice to instead make a composite key for Message of the form (ChatId, MessageId). This would ensure uniqueness, and at the same time I do not need MessageId to be as large as mentioned above, thereby saving some space.
however if messages are to grow without bounds, this is infeasible.
set a buffer size. Only retain the last N entries. Make it configurable so it can scale accordingly to the resources at hand. Anyways, it depends on the kind of chat. If we were talking about an IRC-like chat, doesn't matter, the lines are persisted only on the client-side and they are volatile info we lose when close the chat.This would ensure uniqueness, and at the same time I do not need MessageId to be as large as mentioned above, thereby saving some space.
false. If you are mean to persist ALL the entries, one chat might run short of message Id. then what?