I came across db4o OODB database and wondering how it compares to a traditional stack with an RDBMS or an ORM like Hibernate/EclipseLink. The application is a workflow system and will expand over time. Not sure if an OODB like db4o fits well. I never worked on an OODB so I can't tell. Any suggestions?
2 Answers
Hi! Here is some information based on my own experiences with DB4O.
There are plenty of choices these days for so called OODB's (Object Oriented Databases). Instead of writing a list of these similar solutions, I can tell you how it works as opposed to using a regular RDBMS, because that was your actual question.
You can read a pretty good comparison of some of the most used systems over at Wikipedia: Comparison of OODB's
If you use an ORM persistent methology with a tool like NHibernate, you're giving yourself an easier time when it comes to querying and updating the database behind the persisted objects. You could think of a tool like NHibernate as a "hybrid" solution, while with pure Object Databases like the one you mentioned (one I've done some work with myself) DB4O from Versant / Actian you can choose to work directly with a file on the file-system or opt for a Client/Server kinda solution. DB4O supports both.
The most common scenario would probably be the former mentioned scenario, where you would use a file on the local system to keep persisted copies of your application's objects.
DB4O now exists as a free for non-commercial use product and has both a Java and a .Net version. They both work the same, and from my personal experience they work pretty good for anything from simple 2-10 Mega-Byte databases to files weighing in at around 10-12 GB's.
As a rule of thumb, according to the DB4O developers, if you expect your application's database needs to be larger than around 15-16 GigaBytes, you should consider other approaches.
DB4O is single threaded, and therefor requires a rather speedy CPU Core to handle large amounts of transactions. But, it manages to run really well considering this obvious limitation.
DB4O is easy to expand and should cover most needs for an Object Oriented Database.
Here is a short example that shows how easy it is to connect to and write a series of custom Objects to the DB taken from one of my own projects: (DbPath is a string constant)
public static void StoreObjectsToDb(IEnumerable<SyncObject> syncObjects)
{
using (IObjectContainer container = Db4oEmbedded.OpenFile(DbPath))
{
try
{
foreach (var hdSyncObject in syncObjects)
{
container.Store(hdSyncObject);
Console.WriteLine("Stored Object with HdID {0}\t<-->\tTfsID {1} to database.",hdSyncObject.HdId,hdSyncObject.HdTfsNo);
}
container.Commit();
LogUtility.WriteToLog("Successfully wrote all objects to database.");
}
catch (Exception ex)
{
container.Rollback();
LogUtility.WriteToLog("Could not save objects to database. Rolling back changes...\nError: {0}",ex.Message);
}
finally
{
container.Close();
}
}
}
So as you can see there is a quite simple way to create a new database and populating it with objects, without needing any form of serialization code in the class definitions themselves.
There are support for many of the traditional RDBMS functions in many of the OODB's and in some scenarios the overhead of implementing a regular SQL database is way bigger than simply embedding the database directly into the source.
Hope this clears things up a bit.
Chris

- 2,830
- 19
- 27
-
Thanks for the quick overview. The bounty is yours! Also would you recommend db4o for a medium scale application? – user6123723 Sep 20 '13 at 20:49
-
Well, the term "Medium Scale Application" is very vague. But as I said in the answer, anything up to 10 - 12GB of data should be OK for DB4O. But it really depends on HOW YOU USE the stored data. Does it do a lot of reads or mostly writes (updates) etc. But generally I'd say Go For It! – C. Sederqvist Sep 22 '13 at 14:23
-
Also, as you gave me the bounty, I believe it should also be marked as "the answer"? I may be wrong, I'm new to SO. – C. Sederqvist Sep 22 '13 at 14:29
-
The comment about "if you expect your application's database needs to be larger than around 15-16 GigaBytes, you should consider other approaches" - could you expand on that? 15-16 GB for a database is very very low. Does db4o not handle more? Is it too slow for that? – Ted Oct 23 '13 at 07:56
-
Well, actually no. You could scale your DB4O way above the 15-16 GB limit that I mentioned, but it may not be the most efficient way to solve your problem at hand. It isn't optimized for database larger than a few gigabytes, and mainly for embedded designs. But the theoretical DB size limit for DB4O is actually 254 GB, but that would require you to change the block size like: EmbeddedConfiguration configuration = Db4oEmbedded.newConfiguration(); configuration.file().blockSize(8); But, for scenarios such as this, you're better off with a solution like the Versant Object Database. – C. Sederqvist Oct 24 '13 at 21:08
-
The comparison on wikipedia is actually pretty useless. Gemstone operates fine on a machine with a Terabyte of ram, handling a significant part of the world wide container shipping. – Stephan Eggermont Oct 01 '14 at 22:17
For somewhat larger applications then Gemstone (a persistent smalltalk) is more suitable. That scales easily to the maximum ram supported by a single machine (2/4 TByte?). In Gemstone you'd typically not denormalize to get optimal performance.

- 15,847
- 1
- 38
- 65