# Active Record questions

**URL:** <https://www.ruby-forum.com/t/active-record-questions/92023>\
**Category:** Rails\
**Created:** [April 14, 2007, 6:37pm UTC](https://www.ruby-forum.com/t/active-record-questions/92023 "2007-04-14T18:37:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dparkmit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dparkmit](https://www.ruby-forum.com/u/dparkmit)\
**Post date:** [April 14, 2007, 6:37pm UTC](https://www.ruby-forum.com/t/active-record-questions/92023/1 "2007-04-14T18:37:42Z")

</div>

Hi All,

I’ve just started learning Ruby on Rails. It’s an amazing framework!  
I have some Active Record questions. Any help would be greatly  
appreciated by this RoR n00b!

Active Record has many operations such as :counter\_cache that require  
multiple database queries. In the :counter\_cache example, Active  
Record needs to both create/delete a record in the child table and  
then increment/decrement the counter cache in the parent table.

Does Active Record execute these multiple queries within a single  
database transaction?

If not, how do you ensure that both queries are completed?

If Active Record executes the queries within a transaction, then what  
level of locking does Active Record use? Also, how do you prevent  
deadlock?
