2

How could I draw the database transaction commit in the sequence diagram?

EDIT

I want to draw in sequence diagram database transaction commit/rollback process

gnat
  • 21,442
  • 29
  • 112
  • 288
Roshan
  • 123
  • 1
  • 6
  • Explain in detail what exactly do you want. – treecoder Sep 20 '11 at 16:05
  • You generally don't represent a commit on a sequence diagram (unless you are doing batch inserts, updates, or deletes every n rows where n is a batch size and n>1). – NoChance Mar 15 '12 at 11:15

1 Answers1

4

First, define use cases for the transaction you are modeling. Define versions of the use case for happy path, and each of the rollback scenarios you wish to model. Each of these use case variations can be presented as a separate sequence diagram.

Consider a very simple transaction -- client updates two tables, T1 and T2. Both updates need to succeed, or neither table gets changed. There are three interesting use cases --

  1. The Happy Path -- both updates succeed.

  2. Update to T1 fails.

  3. Update to T1 succeeds, update to T2 fails, update to T1 is rolled back.

So you have three sequence diagrams, one for each case.

The third sequence diagram might look like this:

Client           Database
   |                  |
   |--begin trans.--->|
   |                  |
   |<-trans. started--|
   |                  |
   |----update T1---->|
   |                  |----:
   |                  |    :
   |                  |    DB established rollback point
   |                  |    :
   |                  |<---:
   |                  |----:
   |                  |    :
   |                  |    DB Updates T1
   |                  |    :
   |                  |<---:
   |<---T1 updated----|
   |                  |
   |----update T2---->|
   |                  |----:
   |                  |    :
   |                  |    Update Fails
   |                  |    :
   |                  |<---:
   |                  |----:
   |                  |    :
   |                  |    DB Rolls back T1 Update
   |                  |    :
   |                  |<---:
   |                  |
   |<---trans. error--|
Jay Elston
  • 2,680
  • 22
  • 30