It looks like you're offline.
Open Library logo
additional options menu
Last edited by webchick
April 9, 2008 | History

About the Technology

ThingDB

Building Open Library, we faced a difficult new technical problem. We wanted a database that could hold tens of millions of records, that would allow random users to modify its entries and keep a full history of their changes, and that would hold arbitrary semi-structured data as users added it. Each of these problems had been solved on its own, but nobody had yet built a technology that solved all three together.

So we created ThingDB (tdb), a new database framework that gives us this flexibility. ThingDB stores a collection of objects, called "things". For example, on the Open Library site, each page, book, author, and user is a thing in the database. Each thing then has a series of arbitrary key-value pairs as properties. For example, a book thing may have the key "title" with the value "A Heartbreaking Work of Staggering Genius" and the key "genre" with the value "Memoir". Each collection of key-value pairs is stored as a version, along with the time it was saved and the person who saved it. This allows us to store full semi-structured data, as well as travel back thru time to retrieve old versions of it.

ThingDB is built on top of PostgreSQL, but its interface is abstract enough to allow it to be moved to other backends as performance requires. The current schema of ThingDB tables looks like:

TABLE thing
  id
  parent_id (references thing)
  name (string)
  [(parent_id, name) combinations are unique]
TABLE version
  id
  revision (int)
  thing_id (references thing)
  author_id (references thing)
  ip (ip address)
  comment (string)
  create (datetime)
  [(thing_id, revision) combinations are unique]
TABLE datum
  version_id (references version)
  key (string)
  value (string)
  data_type ('string', 'reference', 'int', 'float', or 'date')
  ordering (integer, default null)

From Python, the tdb interface looks like this:

# create a new book object
foo = tdb.new('foo', testparent, book)
foo.title = "The Story of Foo"
foo.authors = ['Joe Jacobson', 'Robert Daniels']
foo.save()
# retrieve the book object
foo = tdb.withName('foo', testparent)
assert foo.title == "The Story of Foo"
# query for books by that author
foos = list(tdb.Things(author="Joe Jacobson"))
assert foos[0].title == "The Story of Foo"

infogami

But simply building a new database wasn't enough. We needed to build a new wiki to take advantage of it. So we built Infogami. Infogami is a cleaner, simpler wiki. But unlike other wikis, it has the flexibility to handle different classes of data. Most wikis only let you store unstructured pages -- big blocks of text. Infogami lets you store semistructured data, just like ThingDB does, as well as use ThingDB's query powers to sort through it.

Each infogami page (i.e. something with a URL) has an associated type. Each type contains a schema that states what fields can be used with it and what format those fields are in. Those are used to generate view and edit templates which can then be further customized as a particular type requires.

The result, as you can see on the Open Library site, is that one wiki contains pages that represent books, pages that represent authors, and pages that are simply wiki pages, each with their own distinct look and edit templates and set of data.

OL Technology

But infogami is also open to expansion. It has a rich plugin framework that lets us build exciting site-specific features on top of it. So we've added specific Open Library technology to help us handle things like the search engine. We also hope to develop plugins to handle reviews, price checking, and other important features to the site.

Find out more

There's a lot of exciting new technology here and we suspect it will be confusing at first. But there are places you can go for help:

History

March 4, 2009 Edited by webchick changing tech page to i18n type
June 13, 2008 Edited by Anand Chitipothu pushed from staging
April 9, 2008 Created by Alexis Rossi adding page