Database data integrity with a two-phase mechanism

I need experts to please tell me how a two-phase commit mechanism in distributed databases ensures there is data integrity. I am working on an assignment related to database data integrity and this issue seems to be hard. I just need a few pointers on this.
