Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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

share|improve this question
    
Explain in detail what exactly do you want. –  good_computer 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). –  Emmad Kareem Mar 15 '12 at 11:15
add comment

1 Answer

up vote 4 down vote accepted

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--|
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.