# Understanding transactions

1. In operating systems, Is a transaction a process? Are they the same concept?
2. Does a transaction have the same meaning in database management systems, as in OS?

A database book says

A transaction is defined as any one execution of a user program in a DBMS and differs from an execution of a program outside the DBMS (e.g., a C program executing on Unix) in important ways. "

a transaction is an execution of a user program, seen by the DBMS as a series of read and write operations.

In OS, a running program = a process, isn't it?

3. Is there some theory about transactions, or is there math theory underlying transaction management?

Thanks!

• Transactions are atomic, consistent, isolated, and durable. en.wikipedia.org/wiki/ACID. A process doesn't need to be any of those things. There is lots of good theory. Read Gray, Jim; Reuters, Andreas: Transaction Processing: Concepts and Techniques, Morgan Kaufmann, 1992. Dec 12 '14 at 12:24
• @Wandering: Thanks, will check it out.
– Tim
Dec 12 '14 at 12:35

• A transaction in database management system is a collection of tasks to be done by the system with certain guarantees on results depending on the type of the transactions.
• A process in OS is an implementation for a container which runs programs/code. Different kinds of processes (often just two types) have different capabilities.

There is a clear similarity between the two. However, they are different in several ways.

• Transactions do not create new transactions. They have a beginning and an end.
• Processes can create new processes, they have the beginning but they might not have an end

I believe that with PL/SQL, one can manage to accomplish a lot with transaction and with this a transaction might have a close resemblance to a process. For example, with PL/SQL, one can declare variables and use them in the same way that a process stores values and states in its virtual memory address. So in this way, a transaction and a process are very similar. This is about Turing completeness of PL/SQL. Transaction performs task written in PL/SQL language, and process performs task in the OS's programming language (which is the binary code of that OS).

One difference between the two is the way they communicate with each other. Transactions can only communicate indirectly with each other via the results of tasks stored in the database. Process can directly communicate with each other as well as indirectly with each other via side effect on the file system (or similar objects).

1. Transaction is not a process in OS. They are similar concepts, but not the same
2. A program is not a process. This is because a program might be run by multiple processes
3. Of course, there are mathematical models behind transaction. Graphs are often used together with many other things. They use a lot of things in database management system theory. If you want to know more, perhaps a new, specific question will be more appropriate.
• Thanks. About transactions theory. Are there books on the theory that are not limited to OS or DBMS, i.e. can be general and take both as examples?
– Tim
Dec 12 '14 at 0:55
• That I do not know. But pne can argue that books about computation models talk about general models that take both as examples. Dec 12 '14 at 1:04

I don´t know about transactions in operating systems

A transaction in a database, in layman terms, is a set of instructions that must be done all or none.

For instance, suppose that you want to transfer 200 dollars or euros from your bank account to another bank account. The system has substracted 200 dollars or euros from your account, and is going to add that quantity to the other person but then, there is a failure and the operation cannot be completed. You have lost 200 dollars or euros but the other person doesn´t have the money. To avoid that, they invented transactions.

In a database, a transaction is something similar to this:

START TRANSACTION;
UPDATE bank_accounts SET money = money - 200 WHERE user='you'; //You lose 200
UPDATE bank_accounts SET money = money + 200 WHERE user='other_person'; //He wins 200
COMMIT; //Don´t do anything until you get here


No instruction is done if is not possible to get to the commit instruction

In this way, if there is an error doing the transaction, nothing gets done, and the error is prevented

• "I don´t know about transactions in operating systems" -- that's a discouraging way to start an answer about transactions in operating systems.
– Raphael
Dec 15 '14 at 19:30
• I don´t know about transactions in operating systems, but i can explain him what is a transaction in a database, that´s part of the question too Dec 15 '14 at 19:36