Choose the right "Stream Name"

Hello,

I’m trying to implement a very simple PoC with EventStoreDB and I’m asking how to choose the right name for a Stream.

Reading the Stream section of the Requirements for the Storage of Events I see that a valid strategy could be the format [ Schema ].[ Category ].[ Id ] where:

  • Schema: a string, whose purpose is similar to a table schema in the relational world.
  • Category: a string, that identifies the entity type in the event store.
  • Id: a string, that uniquely identifies a stream instance.

My trouble is with the “Schema” and “Category” fields. Suppose you are handling events to handle “Orders” in an e-commerce platform. We might have something like:

Category: order
Id: 550e8400-e29b-41d4-a716-446655440000 (The Order ID)

In this case, the final Stream Name will be:

Stream Name: order.550e8400-e29b-41d4-a716-446655440000

What about the “Schema”? From what I understand, in this case, “Schema” and “Category” might collapse.
Did I miss something? Are there other considerations to do?

Thank you for your help.

If you want to leverage the by category projection this will not work.

Instead, try {Schema}.{Category}-{Id:n}.

So order-550e8400e29b41d4a716446655440000 or sales.order-550e8400e29b41d4a716446655440000.

Something else you might want to consider, is to put the schema into the type field instead. So you would have the stream order-550e8400e29b41d4a716446655440000 and event types like sales.orderPlaced, sales.orderShipped, etc. You can combine this with filtered subscriptions so your read models / event handlers don’t need to worry about types they can’t deserialize.