What’s the best way to store workflow identifiers from Temporal in my own database?

I’m working with Temporal to run communication workflows. A workflow can send multiple communications, and each communication will have metrics about its result. I’m also using schedules to trigger these workflows.

I want to be able to filter in my database the communications of a workflow execution and their related events. The problem is that I’m not sure which identifiers I should store in the database.

One option could be to have the following entities:
WorkflowDef, WorkflowSchedule, WorkflowId, WorkflowExecution, Communications, and Events.
But this feels too complex.

From what I’ve seen, when a schedule triggers a workflow, a different workflow ID is created for each scheduled run, along with an execution_id. Keeping track of all these identifiers seems like unnecessary complexity.

Would it make sense to simplify the model to something like:

  • WorkflowDef, WorkflowSchedule, and WorkflowExecutions (with execution_id),Communications and Events?
    Or maybe:
  • WorkflowDef, WorkflowSchedule, Workflow (with workflow_id), Communications and Events?

Any advice would be really helpful!

What did you end up storing? Your executions started from schedule have access to schedule id and its starttime via search attributes TemporalScheduledById, TemporalScheduledStartTime. If you want to have your workflow id be the business entity id (without timestamp schedules add) you could from worlflow stated from schedule start a child workflow with unique business entity which does business logic processing