Your database is your friend

with Xavier Shay


I am no longer running this course in person, but I partnered with Pluralsight to create a two hour screencast of the material!

Latest news

1st October World Tour complete!

19th August Training in Sweden
Gothenburg, 25th September

17th August New blog post
Updating CTI tables

15th August New blog post
Eager loading CTI tables

10th August Training in Seattle
Seattle, 11th August

5th August New blog post
Constraints assist understanding

4th August Training in Kansas City
Kansas City, 21st August

30th July Training in Scotland
Edinburgh, 13th September

21st July Guest post at EngineYard
An Introduction To Isolation Levels

19th July Guest post at EngineYard
Concurrency and the AASM gem

13th July DBIYF at LSRC
Announcing MongoDB training

6th July New blog post
Five tips for adding foreign keys

5th July Opinion on RailsInside
The perils of opinionated software

4th July New screencast
How AASM is broken and how to fix

2nd July New blog post
Three reasons not to use STI

1st July New screencast
How to debug a deadlock in MySQL

30th June New screencast
How to fix acts_as_list

Learn how to use your database to make your Ruby on Rails applications rock solid.

Rails is an extremely opinionated framework, and our job as professional software developers is to find the “sweet spot” compromise between technologies. Databases have endured a lot of flak from the Rails camp, but they can do some pretty fantastic things. We can make our software better by spending some time to get to know them. Your database wants to be your friend.

A full day training session on using your database to solve the problems that affect every large application.

Yesterday's training with @xshay was the best workshop I've ever attended. Sign up now — you need it! - Geoff Grosenbach, Peepcode

I'm not talking about going back to the days of “enterprisey” stored procedures. Nobody wants that. I will show you that your database has more to offer you than just being a “big hash in the sky”.

Is this course for you?

I designed this course after talking to many of my colleagues who had been using Rails for a few years, and their sites have grown quite large in that time. The early stage was behind them: these were apps that were seeing some serious traffic and turning a profit. They were starting to see problems as traffic had grown, as code that started out as just a prototype started breaking at the seams.

Many of them had computer science backgrounds and had a general idea about what they needed to do with regards to integrity and concurrency, but weren't sure the best way to go about it in a practical setting. I had already been through this process, and spent a large amount of time figuring out the best way to tackle these problems with Rails. My goal with this training is to save you that time.

This course will save you weeks of headaches, troubleshooting and dirty hacks.

If you answer yes to any of the following, you are who I specifically designed this training for:

Do you write code that looks like this?

  if @order.update_attributes(params[:order])
    redirect_to order_path(@order)
    render :action => 'new'
Or this?
  create_table(:orders) do |t|
    t.string :customer_email

  class Order
    has_many :line_items
    validates_presence_of :customer_email
I wouldn't blame you. That's the "Rails Way". Problem is it starts to break down fast when your site starts to grow, and that's just the basic stuff! I hope you're not using acts_as_list or acts_as_state_machine and expecting them to do anything more than hold together a prototype… (New! Watch these screencasts to find out more)

Perhaps you already get weird nils in production? Orders get checked off twice? This training is for you. You need to know about these principles, even if only so you know the cost of ignoring them. If you're building a web application without this knowledge, you're doing it wrong.

Yesterday's "DB is your friend" course by @xshay was phenomenal! I highly recommend going if you can. What you learn may terrify you... - Josh Price, Canoniq


Your database deserves more than to be treated as a second rate hash in the sky. The Rails Way will let you down when it comes to building solid production applications. When done properly, working with your database is not a "vile and reckless destroyer of coherence" (DHH said that)—rather it increases your velocity, quality, and ability to get things done.

Essential knowledge for developers, too long ignored by the rails community. Get the low down on:

Think you know this stuff? Think again…

All theory is backed with tiered rails and ActiveRecord examples, such that beginners can follow along, but there's plenty of bonus material for even the most skilled Rails ninja (or for you to take home and work on later, I'll still be available on email and skype if you have questions). This is a practical course: you will pick up skills that you can apply the very next day.

This isn't a sit-back-and-be-schooled session! Bring your laptop and be ready to code.

On a typical day, we start a fraction late because everyone is still getting coffee. The morning is spent on integrity issues, which everyone deals with pretty well. I lecture for a bit, and then get everyone coding for a bit while I walk around and give individual attention. Maybe this gives rise to questions and discussion. Rinse and repeat. There's some good design exercises in here as well.

Then lunch! Hopefully everyone goes to the same place and we can chat about nerdy things.

The afternoon is concurrency, in the same format as the morning. This melts everyones' brain. It's hard even if you understand it.

I finish off with a bit on transaction vs reporting and other design issues which is mostly just a lecture, and everyone can cope with this at the end of the day. Then we go out and drink beer and shoot the breeze about DB problems everyone is having.

found great value in #dbiyf! Plenty of useful things I can implement right now as well as lots of great advice for future apps... - Ganesh Shankar, Tutoring Australasia

But I don't use MySQL!

All the coding examples are designed for both MySQL and PostgreSQL, and we also discuss the trade-offs between them (which you can apply to whatever database you use most). You should have both databases installed before you arrive, you will be using both.

I know my databases.
How gnarly do you get?

How do you code acts_as_list to work with unique constraints and concurrent access? How do you optimize for concurrent access (1 list, 1000 items, multiple workers)?

What do you do when DB locking can't work for you?

How do you automatically test that your code runs concurrently?

When/what type of implicit locks does MySQL place, and how do you trace down the resulting deadlocks?

How do you fake sequences in a database that doesn't support them (MySQL)?

How do you "close the gap" between an OO model mapped to a relational data store, and ensure your production data is consistent?

Even if you can answer the above questions, do you do it in your rails apps?

it was totally awesome, was great to see all the stuff I should be using! - Chris Herring

Get a taste, right now

I have produced some screencasts that show you how to solve some problems you may be having right now. These are completely free. Even if you don't register for this course, you should set aside 30 minutes to watch these. They will save you time in the future.

This is just a small glimpse of the type of thing the course covers. If you pick up anything new here, you are guaranteed to easily get value out of this course.

How to fix acts_as_list

How to fix acts_as_state_machine

Debugging MySQL deadlocks

Details at a glance


Professional training of this calibre normally costs upwards of $500 a day. I want to get this knowledge out there though—better quality software makes the world a better place to live—so I'm offering this course at a significant discount for only $US350.

DB Is Your Friend by @xshay was an excellent course. You should definitely get involved. - Ben Hoskings

But that's not all. I am so confident in the value of this course that I am offering a full refund to anyone who comes along and doesn't find the training useful. It's risk free. Register below.

I've teamed up with the best Ruby on Rails companies and training providers to offer this session in cities all through Australia, the US and UK.

Where Host When Status
Melbourne Cogent 20 Feb 2010 Success
Melbourne NZX 2 Mar 2010 Success
Sydney ThoughtWorks 10 Apr 2010 Success
Brisbane Mocra 13 Jun 2010 Success
San Francisco Engine Yard 24 Jul 2010 Success
San Francisco Engine Yard 31 Jul 2010 Success
Seattle Blue Box Grp 7 Aug 2010 Success
Seattle pinch/zoom 11 Aug 2010 Success
Chicago HashRocket 13 Aug 2010 Success
Kansas City Databasically 21 Aug 2010 Success
Austin LSRC 25 Aug 2010 Success
Washington DC JumpstartLab 2 Sep 2010 Success
Edinburgh Rubaidh 13 Sep 2010 Success
London SkillsMatter 17 Sep 2010 Success
Winchester Winchester 22 Sep 2010 Success
Gothenburg Elabs 25 Sep 2010 Success
@xshay's db training was very informative. he really knows his stuff. - Ryan Allen, Envato

Questions? Still not sure? Please email or skype me.