Object-Relational Mapping

Vol. 6 No. 3 – May/June 2008

Object-Relational Mapping

Articles

BASE: An Acid Alternative

Web applications have grown in popularity over the past decade. Whether you are building an application for end users or application developers (i.e., services), your hope is most likely that your application will find broad adoption and with broad adoption will come transactional growth. If your application relies upon persistence, then data storage will probably become your bottleneck.

Base: An Acid Alternative

In partitioned databases, trading some consistency for availability can lead to dramatic improvements in scalability.

Dan Pritchett, Ebay

Web applications have grown in popularity over the past decade. Whether you are building an application for end users or application developers (i.e., services), your hope is most likely that your application will find broad adoption—and with broad adoption will come transactional growth. If your application relies upon persistence, then data storage will probably become your bottleneck.

There are two strategies for scaling any application. The first, and by far the easiest, is vertical scaling: moving the application to larger computers. Vertical scaling works reasonably well for data but has several limitations. The most obvious limitation is outgrowing the capacity of the largest system available. Vertical scaling is also expensive, as adding transactional capacity usually requires purchasing the next larger system. Vertical scaling often creates vendor lock, further adding to costs.

by Dan Pritchett

Interviews

A Conversation with Erik Meijer and Jose Blakeley

To understand more about LINQ and ORM and why Microsoft took this approach, we invited two Microsoft engineers closely involved with their development, Erik Meijer and Jos Blakeley, to speak with Queue editorial board member Terry Coatta.

A Conversation with Erik Meijer and José Blakeley

The Microsoft perspective on ORM

In any discussion about ORM (object-relational mapping), Microsofts approach is inevitably a part of the conversation. With LINQ (language-integrated query) and the Entity Framework, Microsoft divided its traditional ORM technology into two parts: one part that handles querying (LINQ) and one part that handles mapping (Entity Framework). To understand more about these technologies and why Microsoft took this approach, we invited two Microsoft engineers closely involved with their development, Erik Meijer and José Blakeley, to speak with Queue editorial board member Terry Coatta.

Meijer is an accomplished programming-language designer who has worked on a wide range of languages, such as Haskell, Mondrian, X#, C-Omega, C#, and Visual Basic (his personal favorite). He runs the Data Programmability Languages Team at Microsoft, where his primary focus has been on removing the impedance mismatch between databases and programming languages. One of the fruits of these efforts is LINQ, which not only adds a native querying syntax to .NET languages such as C# and Visual Basic, but also allows developers to query data sources other than tables, such as objects or XML. Some readers might recognize him from his brief stint as the Head in the Box on Microsofts VBTV.

Articles

A Tribute to Jim Gray

Computer science attracts many very smart people, but a few stand out above the others, somehow blessed with a kind of creativity that most of us are denied. Names such as Alan Turing, Edsger Dijkstra, and John Backus come to mind. Jim Gray is another.

A Tribute to Jim Gray

ERIC ALLMAN

Computer science attracts many very smart people, but a few stand out above the others, somehow blessed with a kind of creativity that most of us are denied. Names such as Alan Turing, Edsger Dijkstra, and John Backus come to mind. Jim Gray is another.

Jim was a giant in computer science, and yet curiously unassuming in person. He would sit quietly at our ACM Queue editorial board meetings, feeling no need to dominate the conversation. When he did speak up, however, everyone in the room would shut up and listen (a difficult feat with that group!), because we all knew that anything Jim had to say would be relevant and interesting. He was also one of the most active board members between meetings, despite being one of those with the most demands on his time. He bore those demands well and with grace. When you talked with Jim on the phone, you could tell that he wasnt reading his e-mail or cleaning up his deskhe was entirely with youand he never seemed to be in a rush.

by Eric Allman

Bridging the Object-Relational Divide

Modern applications are built using two very different technologies: object-oriented programming for business logic; and relational databases for data storage. Object-oriented programming is a key technology for implementing complex systems, providing benefits of reusability, robustness, and maintainability. Relational databases are repositories for persistent data. ORM (object-relational mapping) is a bridge between the two that allows applications to access relational data in an object-oriented way.

Bridging the Object-Relational Divide

ORM technologies can simplify data access, but be aware of the challenges that come with introducing this new layer of abstraction.

CRAIG RUSSELL, SUN MICROSYSTEMS

Modern applications are built using two very different technologies: object-oriented programming for business logic; and relational databases for data storage. Object-oriented programming is a key technology for implementing complex systems, providing benefits of reusability, robustness, and maintainability. Relational databases are repositories for persistent data. ORM (object-relational mapping) is a bridge between the two that allows applications to access relational data in an object-oriented way./

ORM is a specialization of the general concept of object persistence. In his book Object-oriented Analysis and Design with Applications, IBM Fellow Grady Booch claimed that persistence, defined as data that outlives the program, is a minor element of an object model.1 In modern applications, however, the amount of effort devoted to persistence can dominate the cost of a project, and using ORM tools can significantly reduce this cost.

by Craig Russell

Distributed Computing Economics

Computing economics are changing. Today there is rough price parity between: (1) one database access; (2) 10 bytes of network traffic; (3) 100,000 instructions; (4) 10 bytes of disk storage; and (5) a megabyte of disk bandwidth. This has implications for how one structures Internet-scale distributed computing: one puts computing as close to the data as possible in order to avoid expensive network traffic.

Distributed Computing Economics

JIM GRAY

Computing economics are changing. Today there is rough price parity between: (1) one database access; (2) 10 bytes of network traffic; (3) 100,000 instructions; (4) 10 bytes of disk storage; and (5) a megabyte of disk bandwidth. This has implications for how one structures Internet-scale distributed computing: one puts computing as close to the data as possible in order to avoid expensive network traffic.

The Cost of Computing

Computing is free. The worlds most powerful computer is free (SETI@Home is a 54-teraflop machine).1 Google freely provides a trillion searches per year to the worlds largest online database (two petabytes). Hotmail freely carries a trillion e-mail messages per year. Amazon.com offers a free book-search tool. Many sites offer free news and other free content. Movies, sports events, concerts, and entertainment are freely available via television.

by Jim Gray

Exposing the ORM Cache

In the early 1990s, when object-oriented languages emerged into the mainstream of software development, a noticeable surge in productivity occurred as developers saw new and better ways to create software programs. Although the new and efficient object programming paradigm was hailed and accepted by a growing number of organizations, relational database management systems remained the preferred technology for managing enterprise data. Thus was born ORM (object-relational mapping), out of necessity, and the complex challenge of saving the persistent state of an object environment in a relational database subsequently became known as the object-relational impedance mismatch.

Exposing the ORM Cache

Familiarity with ORM caching issues can help prevent performance problems and bugs.

MICHAEL KEITH AND RANDY STAFFORD, ORACLE

In the early 1990s, when object-oriented languages emerged into the mainstream of software development, a noticeable surge in productivity occurred as developers saw new and better ways to create software programs. Although the new and efficient object programming paradigm was hailed and accepted by a growing number of organizations, relational database management systems remained the preferred technology for managing enterprise data. Thus was born ORM (object-relational mapping), out of necessity, and the complex challenge of saving the persistent state of an object environment in a relational database subsequently became known as the object-relational impedance mismatch.

Complex problems sometimes demand complex solutions, and ORM software is no exception. It is necessarily intricate, with multiple facets and components to handle everything from query generation and database write optimizations, to the management of object identity in the virtual machine. The average developer, simply trying to get an application working, may choose to ignore certain complexities of ORM subsystems and their configuration. Understanding fundamental features such as caching, which may be seen as a mere optimization, is critically necessary to intentional and correct application design and should not be overlooked.

by Michael Keith, Randy Stafford

ORM in Dynamic Languages

A major component of most enterprise applications is the code that transfers objects in and out of a relational database. The easiest solution is often to use an ORM (object-relational mapping) framework, which allows the developer to declaratively define the mapping between the object model and database schema and express database-access operations in terms of objects. This high-level approach significantly reduces the amount of database-access code that needs to be written and boosts developer productivity.

ORM in Dynamic Languages

O/R mapping frameworks for dynamic languages such as Groovy provide a different flavor of ORM that can greatly simplify application code.

CHRIS RICHARDSON, CONSULTANT

A major component of most enterprise applications is the code that transfers objects in and out of a relational database. The easiest solution is often to use an ORM (object-relational mapping) framework, which allows the developer to declaratively define the mapping between the object model and database schema and express database-access operations in terms of objects. This high-level approach significantly reduces the amount of database-access code that needs to be written and boosts developer productivity.

Several ORM frameworks are in use today. For example, the Hibernate,1 TopLink,2 and OpenJPA3 frameworks are popular with Java developers, and NHibernate4 is used by many .NET developers. Two newer ORM frameworks that have recently received a lot of attention from enterprise developers are Active Record5 for Ruby6 and GORM (Grails Object Relational Mapping)7 for Groovy.8 These new frameworks differ from traditional ORM frameworks in that they are written in dynamic languages that allow new program elements to be created at runtime. Active Record and GORM use these dynamic capabilities in ways that can significantly simplify an application.

by Chris Richardson

Kode Vicious

The Virtue of Paranoia

Dear KV, I just joined a company that massages large amounts of data into an internal format for its own applications to work on. Although the data is backed up regularly, I have noticed that access to this data, which has accumulated to be several petabytes in size, is not particularly well secured. There is no encryption, and although the data is not easily reachable from the Internet, everyone at the company has direct access to the volumes, both physically and electronically, all the time. Our data center is not particularly well protected either, with just two locked office doors between the outside world and the machines inside.

The Virtue of Paranoia

A koder with attitude, KV answers your questions. Miss Manners he aint.

For the past three-and-a-half years, Kode Vicious has guided many a befuddled programmer toward clarity and understanding. We hope you value his truths from the trenches, and will continue reading the column and sending him your queries as Queue transitions from print to digital. As our digital subscribers already know, e-mailing him will be as simple as clicking on kv@acmqueue.com. He hopes to hear from you soon.

Dear KV,
I just joined a company that massages large amounts of data into an internal format for its own applications to work on. Although the data is backed up regularly, I have noticed that access to this data, which has accumulated to be several petabytes in size, is not particularly well secured. There is no encryption, and although the data is not easily reachable from the Internet, everyone at the company has direct access to the volumes, both physically and electronically, all the time. Our data center is not particularly well protected either, with just two locked office doors between the outside world and the machines inside.

by George Neville-Neil

Curmudgeon

There's a Lot of It About

"A lot of what, and about where?" I hear you cry. One question at a time, I reply. First, there's too much of everything these days, and, second, it's happening all over. Furthermore, everybody's doing it. As a contemporary Wordsworth might say: "The Web is too much with us, late and soon, getting and browsing we lay waste our powers." There is a glut of unfiltered information proving more dangerous than Alexander Pope's "A Little Learning" where "shallow draughts intoxicate the brain."

Theres a Lot of It About

And everybodys doing it.

Stan Kelly-Bootle, Author

A lot of what, and about where? I hear you cry. One question at a time, I reply. First, theres too much of everything these days, and, second, its happening all over. Furthermore, everybodys doing it. As a contemporary Wordsworth might say: The Web is too much with us, late and soon, getting and browsing we lay waste our powers. There is a glut of unfiltered information proving more dangerous than Alexander Popes A Little Learning where shallow draughts intoxicate the brain. Pope surely predicts our age of instant, effortless data access when he writes:

/But, more advanced, behold with strange surprise
New distant scenes of endless science rise!

by Stan Kelly-Bootle

Articles

Ode to a Sailor

sailor, fleeting mood image of you; all sailor in bear grace, rough hands and poetic dream;

Ode to a Sailor

DONNA CARNES

by Donna Carnes