Reputation: 1967
I'm writing a system for putting items in player's inventory for a game and I am wondering how separate queries will affect running transactions in SQL Server. For example:
But the whole game server has a lot of separate queries and subsystems that will run without it being in a transcation... like updates in inventory, money, and player's status.
How exactly transactions work? I mean its just like critical sections on C++ that you need an object to lock against (in this case my procedure) or it does lock for separate queries too? I'll need to put everything inside a transaction when updating?
Since I'm self-taught learner for everything related to programming, somethings gets missed. Sorry.
Thank you.
Upvotes: 0
Views: 330
Reputation: 1654
The way I understand it, a transaction in a database is a single or group of queries that are to be treated in an "all or nothing" fashion, or rather if one of the queries doesn't work, the database will be rolled back to it's state before they happened. Locking doesn't necessarily need to be used during every transaction but is used when database changes are critical and should take place before any other process or query should have a chance to alter the data affected by the lock.
Here's an article that may explain this even better:
Upvotes: 1