Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Friendly: Easy Schemaless “NoSQL” Data Storage with MySQL in Ruby

By Peter Cooper / December 21, 2009

friendly.png Friendly is a new Ruby ORM (a la ActiveRecord) that lets you easily use NoSQL ideas on regular database engines, such as MySQL. Developer James Golick has written a blog post introducing Friendly that goes into detail on how it works - with code examples. Effectively you get schema-less, document-like storage (with indexes!) but based around MySQL.

If you're not familiar with "NoSQL", it's a blanket/branding term (somewhat like AJAX or Web 2.0) that covers non-relational forms of databases that, typically, have no need for SQL. A common subset of NoSQL technologies is the "document-based database," as provided by systems like CouchDB or MongoDB (for which RailsTips author John Nunemaker has evangelized strongly).

An issue many people are having with the various NoSQL systems available is that they're not all "battle hardened" or as familiar to administer than their existing MySQL or Postgres systems. Social aggregator FriendFeed wrote about how they use MySQL to store schema-less data, and Friendly is based on the same techniques.


  1. @pauliephonic says:

    I created something similar last year called HybridDB. You can find it here: and some explanation and tutorials here:

    I had abandoned the whole idea of schema-less db after it didn't fit a few projects which needed non ruby access to the data. Glad to see someone finding it performant enough for a large public site. I'll maybe revisit the idea, I had a few other ways I had wanted to take the concept.

  2. Hubert Łępicki says:

    I think the whole idea of schema-less database is not right. Don't get me wrong, I like the ability to add fields ad I need it, but I always end up using some sort schama for my data. Even today, when I use MongoDB with MongoMapper I define fields in my model. I don't need a migration any more and I can add some extra fields in future easily, but I do:

    class MyClass
    include MongoMapper::Document
    key :something, String
    key :otherthing, Integer

    I know that in some situations it's not enough, but it's good for 90% of my needs.

    About mentioned solution with MySQL... is it only me thinking it's not justified and misuse of relational database? Still see no point in why I just wouldn't use Mongo. Or Couch. Or something that was designed to be schema-free.

  3. logan says:

    I also did a NoSQL style rails plugin that runs on top of MySQL, for much the same reason that FriendFeed did. See my repos at and These have been in production at for about 9 months.

    Schema-less in the database doesn't have to mean that at the ORM layer there is no schema. My plugin defines a schema in each model using a simple DSL instead of defining it in the db schema, much like what Hubert illustrates above. Simple migration plus the benefits of having some definition around attributes.

  4. marc says:

    do you mind changing the title of this article every time i see it in my rss reader i misread schemaless and get disturbing images in my head

Other Posts to Enjoy

Twitter Mentions