First of all, think "Transaction" as a concept, which is nothing but a guarantee that a sequence of operations will be done atomically (consistent, isolated and durable as well making the ACID property).
If any of the operation fails, the actions performed by previous operations in that transaction will be rolled back.
Now in Erlang, you have different types of transactions supported [ Check here ]:
- transaction (regular one)
- sync_transaction (waits until all active replicas has committed the transaction (to disc) )
- async_dirty (No locking and updates are done asynchronously)
- sync_dirty (same as async_dirty, just that the call will wait until all nodes are updates)
- ets (For RAM copies which doesnt scale out to multiple nodes)
Now, back to the question, What is Activity then ?
How I see it is, activity provides me with a generic interface using which I can hide the details of like which kind of transaction I am actually doing. In your application, you may have different consistency and performance requirement in different parts or functionalities.
So, you can just pass the type of transaction you want to do as the first parameter of the activity call [ Check Here ].
Besides that, the biggest difference is, activity lets you customize the access mode of records in Mnesia (Explained in the second link). Which I must say, must be done by a very experienced erlang programmer only. For most of the cases the default one provided must suffice.
Excepts from the documentation:
This function (mnesia:activity/4) differs in an important aspect from the mnesia:transaction, mnesia:sync_transaction, mnesia:async_dirty, mnesia:sync_dirty and mnesia:ets functions. The AccessMod argument is the name of a callback module which implements the mnesia_access behavior