The Artima Developer Community
Sponsored Link

Java Community News
Gavin King: In Defence of the RDBMS

195 replies on 14 pages. Most recent reply: Jun 20, 2007 6:11 AM by James Watson

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 195 replies on 14 pages [ 1 2 3 4 5 6 ... 14  | » ]
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Gavin King: In Defence of the RDBMS Posted: May 25, 2007 4:01 PM
Reply to this message Reply
Summary
In a recently posted blog entry, Gavin King notes the real significance of relational databases in the enterprise, and addresses the key challenges of object-relational mapping.
Advertisement

In his most recent blog post, In defense of the RDBM, Gavin King notes that,

If you think that relational technology is for persisting the state of your application, you've missed the point. The value of the relational model is that it's democratic. Anyone's favorite programming language can understand sets of tuples of primitive values. Relational databases are an integration technology, not just a persistence technology. And integration is important. That's why we are stuck with them.

Most of King's blog is focused on comparing relational databases to other, especially object-based, databases:

Every couple of months we are unsurprised to see yet another announcement by some company or open source group who has solved the "complexity" of Object Relational Mapping (ORM) by eliminating the relational database. Great leaps in developer productivity are promised, together with astonishing performance increments... Paradoxically, enterprise adoption of these technologies remains approximately zero. What's going on here?

King's main point is that relational databases are more than a mature technology, and are a shared repository of information that will need to exist long after programming languages and programming paradigms have come and gone. He also makes a few pointed references to Ruby and Rails.

What do you think of King's ideas about the roles relational databases play in the enterprise?


Morgan Conrad

Posts: 307
Nickname: miata71
Registered: Mar, 2006

Re: Gavin King: In Defence of the RDBMS Posted: May 27, 2007 12:36 PM
Reply to this message Reply
Has Gavin ever used db4o? It would really open his eyes. (And, for all his talk of objectivity, looks like he works for Hibernate)

As for OODBs being Java dependent, if one believes the (possibly hype) that Service Oriented Architectures will take over the world, who cares? Your VB or Ruby or FORTRAN 2123 will talk to a service, not a DB, to get the data. Wrap your Java OODB in a Service and anybody can talk to it.

And RDBs implementations never change. Nor do their schema, columns, triggers, rules on IDs and nulls, etc. Cause if they did it would break the VB code talking to it. Oh darned - they do change.

Here's a real world example I am wrestling with right now.
We have a Java app using Hibernate/Spring etc. to talk to a RDB. We want to backup an object from one DB to another on a different computer the user selects at runtime. ApplicationContext.xml has the URL of the DB. But it's all DIPed at startup. I'm finding it really hard to figure out how to recreate the complete DataSource/SessionFactory/HibernateTemplate at runtime to point to the other place. Because normally it is all "handled" for you by Spring parsing the XML files at startup and filling in with Proxies. Programmers, in general, don't do the actual work themselves cause it's so complicated - that's what Spring is there for. I ended up calling getClass() on one of the Proxies then getInterfaces() to figure out just what the heck I could do with it. Still stuck. BTW - anybody know how to do this? Maybe Gavin has a "Advanced Hibernate Consulting" group?

In DB4O it would be one line of code to connect to another database. Instead of incredible complexity requiring layers and layers of (useful) open source projects, you just write one line of code.

Kevin Teague

Posts: 15
Nickname: wheat
Registered: Mar, 2006

Re: Gavin King: In Defence of the RDBMS Posted: May 27, 2007 4:45 PM
Reply to this message Reply
Having used the ZODB (Zope Object Database), a Python object database,
for many years, as well as a number of relational databases/ORMs, I thought
I'd respond to some of these points from the perspective of a Python
developer.

complexity
There is a lot of complexity in using a relational database
with an ORM. Keeping a seperate RDBMS running, configuring, learning and
optimizing the ORM. It's a lot more code than an ODB.

The converse is that it's that understanding a relational database schema is
a ubiquitous skill, so you can have increased developer complexity in
understanding the modeling of objects.

It can be a real joy to just work with objects though, as you have to much
less thinking about how to persist those objects. You are also free to
make your objects as complex as you desire, complex issues such as model
inheritance and complex attributes are just handled so cleanly.

performance
This is really going to depend upon what your data model
looks like. Sometimes object databases will perform better and sometimes
relational databases will outperform better. It seems like there are some
rather pointed benchmarks that set off Gavin to posting his rant, and any sort
of statement such as "object databases are X times faster than relational
databses" is just silly.

It is worth noting that the ZODB can run in-process or stand-alone,
listening on a TCP/IP port, just like a RDBMS. This kind of flexibility is a
good benefit if you ever need to deploying a client application that needs
it's own local persistence.

You can scale the ZODB across as many servers as you need using ZEO
(Zope Enterprise Objects), and have mutliple redundant primary object stores.
All following the same principals as a RDBMS. Object databases by their nature
do make it much easier to handle changes to the schema across your database
cluster though.

integration
It really depends upon what kind of system you are building,
but when I use the ZODB it's often to support a web application, where you are
going to need some a web service API. Often these are more democratic than a
relational database, as they are often easier to expose outside your internal
network.

Conversely, many people are still much more familiar with SQL than web
services, and SQL gives you a very good 'for free' API, so this just comes
down to the nature of your particular projects goals.

I have also witnessed the curious nature of how the management of even
smaller relational databases can end up falling across multiple
departments. Developers whose hands are tied because management of relational
databases is handled by another group. Where as object databases are not
recognized as a 'database', and so other developers using that technology
are free to manage their data as they see fit (for better or worse).

security
This is a good benefit for object databases, as they are
inherently more secure than a relational database, as you do not have to worry
about SQL injection attacks.

enterprise
The ZODB has been around for about 8 years, so it's
reasonably mature. It is always a trade-off, as tools for working with it are
just not going to compare to the ecosystem that has grown up around Oracle
or MySQL.

The ZODB is the data storage for Plone, which is making it's way into a few
enterprise-sized organizations. There are a few of Fortune 500 companies using
this technology, so while adoption of object database technology in the
enterprise is low, it's not zero. This is partly a political thing, if your
organization has invested X millions of dollars in a J2EE/Orcale solution,
and you come out and say, 'we replaced a relational database backed stack
with an object database one, and we got much better performance with the
object database backed technology', when you next go back to your vendors to
renew your contracts, they aren't going to be so eager to negotiate on price.

Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: Gavin King: In Defence of the RDBMS Posted: May 28, 2007 5:17 AM
Reply to this message Reply
I would like to add a 2nd comment on db4o: it's the easiest database I have ever used, and it have shortened development times by many orders.

Db4o is as relational as traditional RDBMs are: you can model any relationship you like, and it will be persisted, and you get one thing that you don't get with traditional RDBMSs: datatype polymorphism.

Performancewise, the db4o approach is better than traditional RDBMSs, because there is no translation from/to native/database formats, and you don't always have to fetch data to do a computation, you can send the computation to the data.

There is also another benefit: records need not be of fixed length. For example, strings can be stored and retrieved as parts of objects, without needing to specify a fixed length, as in traditional databases.

Another big benefit of db4o is type safety: you don't have to run queries on the database. The compiler's type checking is more than enough! if your query is wrong, then the code will not compile.

The biggest benefit of db4o is that there is no problem when schemas change: you don't have to do anything, it is automatically taken care for you. As long as code compiles, there is no problem.

The only "drawback" of db4o is that no one knows it. Everyone knows Oracle, SQL Server, DB2, maybe MySQL, so that is what they ask for. There is a whole industry around commercial databases. I have used db4o for internal projects, and developing internal applications could not be easier (Java + webstart + db4o), but our clients would not accept it.

I have found db4o because I was searching for an altenative to Hibernate. Hibernate to db4o is like CP/M to Windows NT: with Hibernate, a trivial project like a sales database (customers, products, sales) can take a few days to code, whereas with db40 it takes about a few minutes!!!

I wish Sun adopted db4o and made it part of the basic package. A lot of programmer headaches would go away.

Kay Schluehr

Posts: 302
Nickname: schluehk
Registered: Jan, 2005

Re: Gavin King: In Defence of the RDBMS Posted: May 28, 2007 9:05 AM
Reply to this message Reply
Thanks for the defence of the OODBMS in the comments section! These were really helpfull recommendations.

robert young

Posts: 361
Nickname: funbunny
Registered: Sep, 2003

Re: Gavin King: In Defence of the RDBMS Posted: May 28, 2007 1:54 PM
Reply to this message Reply
Mr. King's not perfect (only Dr. Codd was), but he mostly gets it.

One point: the current SQL standard contains syntax for IMS (aka, hierarchical) style manipulation.

But his main point remains: Dr. Codd's paper was about Large Shared Databanks. Data matters and is eternal; code is the product of whimsy.

It is also provable that the execution path of a function is shorter if it's in the database than if it's in the Client Code. And more reliable, secure, etc. You can eat tomato soup with ten foot chopsticks, or a 3 inch spoon. Which makes for sense? COBOL-ers from the 1960's always chose the chopsticks, because they didn't know any better; and there wasn't an option. The OO folk seem to be doing the same thing, even when they have an option.

I don't have the citation to hand, but one of my favorite quotes: "It's easier to understand 600 tables than 100,000 lines of code". Yes, Brother.

robert young

Posts: 361
Nickname: funbunny
Registered: Sep, 2003

Re: Gavin King: In Defence of the RDBMS Posted: May 28, 2007 1:57 PM
Reply to this message Reply
> security
> This is a good benefit for object databases, as they are
> inherently more secure than a relational database, as you
> do not have to worry
> about SQL injection attacks.

Strawman. Solved problem ages ago. Or, do you mean security by obscurity? The SQL interface/API is available on all platforms/languages/whatever. There is nothing more universal. That doesn't mean it's insecure, ceteris parabus.

Kevin Teague

Posts: 15
Nickname: wheat
Registered: Mar, 2006

Re: Gavin King: In Defence of the RDBMS Posted: May 28, 2007 6:30 PM
Reply to this message Reply
Object databases can be more secure because you are not executing any
untrusted data. Sure all goods developers know about SQL injection attacks
and there are many good ways to prevent them, but it's still not as secure
as just not having the problem. With an object database, you take untrusted
user input and store it on disk - skipping completely the intermediate
step where you need to execute SQL on your database server. There is no
such thing as an Object Injection attack.

Kevin Teague

Posts: 15
Nickname: wheat
Registered: Mar, 2006

Re: Gavin King: In Defence of the RDBMS Posted: May 28, 2007 6:53 PM
Reply to this message Reply
> Performancewise, the db4o approach is better than
> traditional RDBMSs, because there is no translation
> from/to native/database formats, and you don't always have
> to fetch data to do a computation, you can send the
> computation to the data.
>
> There is also another benefit: records need not be of
> fixed length. For example, strings can be stored and
> retrieved as parts of objects, without needing to specify
> a fixed length, as in traditional databases.

Skipping translation to/from database formats is going to improve
performance. But the fixed length nature of a relational database
can greatly improve read performance, at least as far as I understand it,
which is mostly coloured by this Joel on Software article (skip halfway
down to the part where he talks about SQL):

http://www.joelonsoftware.com/articles/fog0000000319.html

Now this is comparing SQL to XML, so obviously object databases don't have
all of the parsing overhead of XML. But object databases do have the design
limitation that if you have large objects, and you want to query a lot of
these large objects for just a single attribute, it is necessary to
'wake up' all data associated with each object, even if you only care about
a single attribute.

Morgan Conrad

Posts: 307
Nickname: miata71
Registered: Mar, 2006

Re: Gavin King: In Defence of the RDBMS Posted: May 28, 2007 9:07 PM
Reply to this message Reply
> Data matters and is eternal; code
> is the product of whimsy.

Tell that to Intel. The reason 8080 emulating CPUs are dominant is because of Code, not Data.

Mark Thornton

Posts: 275
Nickname: mthornton
Registered: Oct, 2005

Re: Gavin King: In Defence of the RDBMS Posted: May 29, 2007 1:39 AM
Reply to this message Reply
> all of the parsing overhead of XML. But object databases
> do have the design
> limitation that if you have large objects, and you want
> to query a lot of
> these large objects for just a single attribute, it is
> necessary to
> 'wake up' all data associated with each object, even if
> you only care about
> a single attribute.

No, the access to the attribute need only 'wake up' data that is in the same (memory) 'page' as the required attribute. There are numerous ways of achieving this, with relying on a virtual memory system probably the simplest for the programmer.

Tony Marston

Posts: 37
Nickname: tony32
Registered: May, 2007

Re: Gavin King: In Defence of the RDBMS Posted: May 29, 2007 3:00 AM
Reply to this message Reply
To answer the question: “is relational technology just there to persist the state of your application?” my answer is an emphatic NO. The contents (and structure) of a database is an asset in its own right, is quite separate from the application code, and can (and is quite often) used by more than one application, perhaps even in more than one language, at the same time. The structure of a database is very important – get it wrong and the job of writing code, and the performance of that code, will suffer. I have been writing CRUD applications for several decades in a variety of different languages, so I have personally suffered the consequences of poor database design.

One of the most valuable lessons I learned years ago in a structured programming course was (a) get the structure of your database right, and (b) structure your code around the database. If the application structure and database structure are out of sync then you are simply making a rod for your own back. I have also seen the long term advantages of changing the database structure, and changing the code which accesses those structures, should the requirements change. If you try to take a short cut and change nothing but the code you are simply storing up problems behind the wall of a dam – one day the dam will burst and all those little problems will drown you.

The biggest mistake that OO programmers make is to start their design with the application and leave the database till last. When the database is designed by someone who understands the rules of normalisation it quickly becomes obvious that there is a serious mismatch, which is where an Object-Relational Mapper (ORM) comes into play. An ORM is only necessary when the structure of an application object is different from the structure of the equivalent object within the database so that it can convert from one structure to the other in all communication between the two.

This is why a lot of OO programmers cry out for an OO database, simply to cover up their mistakes. They want something into which they can drop their badly designed objects instead of having to map to a properly normalised structure.

To me the use of an ORM is a big mistake. It is an extra level of complexity, it is an extra processing overhead, and it is a sign that the software architects are singing from the wrong hymn sheet. When I made the transition from procedural to OO programming I continued to use the lessons learned in my structured programming course – design the database first, then design the application around the database. As a consequence I have a separate class for each database table. My class hierarchy is also very simple – all the code which is common to any and every database table is defined within an abstract table class which is then inherited by every concrete table class.

I have built upon this simple design by automating the generation of class files – simply import the database structure into my custom-made data dictionary, then press a button and the basic class file will be built for you. For each database table there is also a separate file which identifies the structure of that table. Should the structure of any table change it is a simple matter to re-import into the data dictionary so that it can synchronise itself, then re-export to the application. In this case only the structure file will be overwritten, not the class file, as it may have been modified to include custom code.

The advantage of using a separate class for each table is that all the rules for making changes to that table are held in that single class. If I need to modify that table I simply pass the data to that table’s object using the relevant insert(), update() or delete() method, then check the number of errors produced within that object. It does not matter how many different components within the application need to access that table as they all do it through that table’s object. Many components can share the same object, so I can change the rules once within that object and those changes are instantly made available to every component within the application. Sometimes a change to the database structure does not require any changes to custom code, so implementing that change is as simple as (a) import from database into data dictionary and (b) export from data dictionary to application.

ORMs? I don’t need no stinking ORMs.

Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: Gavin King: In Defence of the RDBMS Posted: May 29, 2007 4:09 AM
Reply to this message Reply
> This is why a lot of OO programmers cry out for an OO
> database, simply to cover up their mistakes. They want
> something into which they can drop their badly designed
> objects instead of having to map to a properly normalised
> structure.

That's not true. You have to normalize the objects just like you normalize the database. Normalization is not a function of database implementation, but a fundamental property of information organization.

Ravi Venkataraman

Posts: 80
Nickname: raviv
Registered: Sep, 2004

Re: Gavin King: In Defence of the RDBMS Posted: May 29, 2007 5:14 AM
Reply to this message Reply
Tony,

Great comments.

As far as one table per class is concerned, I have two questions. One, can the insert, update, delete operations for table-classes be generalized so that we have one class per application that accepts a table name and class name (or gets one and infers the other) and performs the required CRUD operation? The second question is - why not use views instead of tables so that table structure changes are insulated from any application code?

I, too, have long believed that ORMs are unnecessary and are made necessary only because OO programmers lack knowledge and understanding of relational database concepts. Whenever I express my view that ORMs are unnecessary, I'm met with a litany enumerating the benefits of ORMs. It is very difficult to convince people that all the effort invested in ORMs is essentially a waste of time.

One of the best quotes I've come across is, " Data stays, applications come and go." As anybody with a few years of experience in the software world can attest, that is a fact.

Ravi Venkataraman

Posts: 80
Nickname: raviv
Registered: Sep, 2004

Re: Gavin King: In Defence of the RDBMS Posted: May 29, 2007 5:17 AM
Reply to this message Reply
Great comments. I, too, simply cannot understand the statement that OODBMS are more secure. This is contrary to my experience that a RDBMS (or SQL database) is very secure and one can easily provide very fine-grained access to data, something that may not be possible using OODBMS.

Flat View: This topic has 195 replies on 14 pages [ 1  2  3  4  5  6 | » ]
Topic: JavaOne, Day 3: Java Puzzlers Previous Topic   Next Topic Topic: Josh Davis Explains JavaScript's Prototype Objects

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use