In SQL DB, the changes you make to the database is not reflected to the physical database until you commit the transaction. The basic structure is:
1) SQLTransaction1.StartTransaction; // or SQLTransaction1.Active := True;
2) do database operations --- insert, delete or update
3) SQLTransaction1.Commit; // or SQLTransaction1.Rollback;
The changes done in step 2 are not reflected to the final physical database until you commit or rollback at the step3. If you rollback it, the changes are abandoned. So a block of operations that should be done together are grouped within a transaction.
You'd better manually commit or rollback transaction yourself. The timing is important for the database integrity.
Transaction is related with SQL database. Even though you do many things with different dataset descendants, all the changes done to the database is within one transaction. For example, you may write
SQLQuery1.SQL.Text := 'insert into table1 values (1,2,3,4,5)';
SQLQuery2.SQL.Text := 'update table2 set f1=12345 where field2=99';
if not SQLTransaction1.Active then SQLTransaction1.StartTransaction;
SQLQuery1.ExecSQL;
SQLQuery2.ExecSQL;
SQLTransaction1.Commit;
Here, both changes of SQLQuery1 and SQLQuery2 may be committed or rollbacked at the same time, not separately. If you want to do that one by one, you have to do
SQLQuery1.SQL.Text := 'insert into table1 values (1,2,3,4,5)';
SQLQuery2.SQL.Text := 'update table2 set f1=12345 where field2=99';
if not SQLTransaction1.Active then SQLTransaction1.StartTransaction;
SQLQuery1.ExecSQL;
SQLTransaction1.Commit; // or rollback
SQLTransaction1.StartTransaction;
SQLQuery2.ExecSQL;
SQLTransaction1.Commit; // or rollback
You can commit or rollback each of SQLQuery1 or SQLQuery2 changes.
Or you may assign different transactions to SQLQuery1 and SQLQuery2, e.g.
SQLQuery1.Transaction := SQLTransaction1;
SQLQuery2.Transaction := SQLTransaction2;
But in most cases, only one transaction is sufficient.
So, in many forms, if the transactions are contained in each form, then there are as many transactions as the number of forms. If you put database component and transaction component in one datamodule and datasets in each form (which is recommended), then you have only one transaction. You must be careful when to set active and commit/rollback the transactions at each form.