<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>emphess .NET &#187; Object Database</title>
	<atom:link href="http://www.emphess.net/tag/object-database/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emphess.net</link>
	<description>Freshly Draught Code</description>
	<lastBuildDate>Fri, 11 Nov 2011 11:57:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>My db4o Wishlist</title>
		<link>http://www.emphess.net/2010/04/14/my-db4o-wishlist/</link>
		<comments>http://www.emphess.net/2010/04/14/my-db4o-wishlist/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 22:30:18 +0000</pubDate>
		<dc:creator>Christoph Menge</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[db4o]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[Object Database]]></category>
		<category><![CDATA[OODBMS]]></category>

		<guid isPermaLink="false">http://www.emphess.net/?p=168</guid>
		<description><![CDATA[After finding that db4o did not screw up in our projects, I dug a bit through their issue tracker, which is a very important resource you should definitely check out if you&#8217;re working with db4o! Just to get that straight: I&#8217;m an avid db4o user and really love it. These issues are not critical and [...]]]></description>
			<content:encoded><![CDATA[<p>After finding that <a href="http://www.emphess.net/2010/04/12/nosql-approaches-trying-to-use-db4o-in-the-real-world/">db4o did not screw up</a> in our projects, I dug a bit through <a href="http://tracker.db4o.com/secure/Dashboard.jspa">their issue tracker</a>, which is a very important resource you should definitely check out if you&#8217;re working with db4o!</p>
<p>Just to get that straight: I&#8217;m an avid db4o user and really love it. These issues are not critical and they don&#8217;t stop me from using or evangelizing db4o. However, I think there is some lack of awareness of some issues.</p>
<p>Also, I&#8217;d like to spawn some discussion about the issues below. Unfortunately, due to their changes to the forum system, most of the original discussions on the <a href="http://developer.db4o.com/Forums.aspx">db4o forum</a> are hard to find or possibly lost. You may want to <em>vote on the issues you deem most pressing</em>, which you can easily do in their issue tracker! I&#8217;m very interested in what you think about this little selection.</p>
<h2>Selected Issues</h2>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-1133">Don&#8217;t run SODA when no more constraints are present</a><br />
I <a href="http://www.emphess.net/2010/03/16/db4o-queries-on-large-datasets-and-a-bit-of-linq/">blogged about this already</a>, because you experience this in very common scenarios, namely whenever you query a small subset of a larger candidate set. For example, consider selecting the last 50 posts on a blog/qa-site/etc. What will happen is that db4o runs the BTREE query for the sort operation (blazing), <em>then hydrates (?) all objects</em>, the returns the first 50 of them and throws away the rest. Thing is that there is no need to further inspect the items, and activating all them is basically a linear operation. Thus, this common type of query currently runs in <em>O(n)</em> instead of <em>O(log n)</em> which is an incredibly dramatic difference.</p>
<p><span id="more-168"></span></p>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-1899">LINQ-Implementation is not &#8216;thread&#8217;-safe</a><br />
A very <a href="http://blog.stevensanderson.com/2007/11/29/linq-to-sql-the-multi-tier-story/">similar issue has been on LINQ-to-SQL&#8217;s todo list some time ago</a>.<br />
I&#8217;m not sure whether this is so much the typical use case. For the db4o case, it teaches us two things right now:</p>
<ul>
<li>Container reuse is non-trivial and should be approached with extreme care. You don&#8217;t want to run into this kind of byzantine error in a live app.</li>
<li>The object identity problem is similar in both Object-Relational Mapping and OODBMS</li>
</ul>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-191">Scalable server architecture: multiple readers against the same file, transactional files</a><br />
This sounds daunting, and it&#8217;s probably a huge one, as you can see from its age. I also believe this might be politically challenging, because this moves into the direction of <a href="http://www.versant.com">Versant&#8217;s</a> large-scale object database. However, there is a lot of movement into that direction from the user-side it seems &#8211; people are asking for features of this kind more and more lately, largely due to the ultra-cool LINQ integration db4o has. I suppose I&#8217;d be wise to focus on this kind of scenario as it could really become the preferred way of writing web applications: it&#8217;s extremely agile, supports rapid development, is flexible in that the same (LINQ) code could be used for different persistence layers if that should ever be needed and leads to clean, compile-time checked, type-safe code.</p>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-236">Sanitize reflector design &#8211; remove core dependencies on generic reflector</a><br />
Being able to get rid of the generic reflector seems important, I&#8217;m already building my own code for this. Here we have conflicting requirements: The GenericReflector makes db4o very easy to use and may help beginners. It is also required in client-server scenarios where the server doesn&#8217;t have the necessary model dlls, but for most applications I think you should try to avoid it. Storing data in a generic manner is slow and requires a lot more space, making it highly inefficient.</p>
<p>Current attack vector: <a href="http://developer.db4o.com/Forums/tabid/98/aff/4/aft/9635/afv/topic/Default.aspx">Throw a Listener on the object created event</a> on the server and make sure the server knows the type.</p>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-1905">Allow immediate TCP port reuse</a><br />
When opening a server, the TCP port will be blocked in case the server crashes, the app is terminated, etc. Since that might happen quite often when you use the &#8216;integrated server&#8217; where the server is actually created in your web application, a restart of the web application will fail because the TCP port is blocked. In a client-server scenario, on the other hand, a simple restart wouldn&#8217;t be possible because you need to assign a new port to clients or wait 6 minutes. This should be fairly simple, but I don&#8217;t know if that comes with any side-effects.</p>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-113">Fast Collections</a><br />
This is a huge one. The cool thing is that this could allow much more complicated queries to be executed in reasonable timeframes. However, I&#8217;m a bit worried about <a href="http://tracker.db4o.com/browse/COR-644">the issue &#8220;FastCollections: Inside BTree List implementation&#8221;</a>, because that sounds really important, but is in state &#8220;Won&#8217;t fix&#8221;.</p>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-478">Locking</a><br />
Optimistic locking would be a nice-to-have thingie, but you do this yourself rather easy I think.</p>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-1772">A new object is stored upon value type updates</a><br />
This is rated critical, so it&#8217;s not an item for a &#8220;wishlist&#8221;. I&#8217;m not sure if I understand its implications and I rarely use value types apart from Guids, and updating Guids is pointless &#8211; still a db4o user should probably know this and keep this in mind, so I felt it should go here &#9760;.</p>
<h2>db4o Configuration</h2>
<p>This one is not really in the issue tracker as a single item, and it&#8217;s more of a general remark. <em>One of the rather messy things in db4o is configuration</em>. Even with the <a href="http://programing-fun.blogspot.com/2008/10/changes-in-db4o-configuration.html">new configuration interface</a>, there is quite a bit of confusion among users. The reason, in my eyes, is mostly a combination of incomplete documentation and unexpected behaviour. Examples:</p>
<ul>
<li>The indexation setting for fields is the only configuration setting that is persistent. Everything else, including unique constraints, needs to be re-set when (or &ndash; more precisely &ndash; <em>before</em>) opening the <code>ObjectContainer</code>.</li>
<li>Applying an option to a field that doesn&#8217;t exist will not trigger a warning or an <code>Exception</code></li>
<li>Some settings simply won&#8217;t have any effect when you perform them after opening the <code>ObjectContainer</code>, but they do not warn you.</li>
<li>Certain settings <strong>must</strong> be applied on the server, a few <strong>must</strong> be applied on the client and with some &#8230; well, you just set them on both just to make sure. Here, db4o does throw exceptions, however!</li>
<li>Several options need to be set before <em>creating</em> the object container (e.g. string encoding) and cannot be reset afterwards, again being completely silent about the ineffectiveness of the respective settings.</li>
<li>Some settings, such as field-based cascade-on-activate, <a href="http://developer.db4o.com/Forums/tabid/98/aff/4/aft/9783/afv/topic/Default.aspx">simply don&#8217;t seem to work at all</a></li>
</ul>
<p>This leads to lots and lots of confusion. Most importantly, it is often hard to determine whether a certain setting was successfully applied, or not. Also, some defaults are unexpected:</p>
<ul>
<li>Default <code>ActivationDepth</code> is (completely random) 5. Why not 8? Or 2? This troubles beginners a lot. Either set it to infinity, or to zero. Everything else feels just random. You can still include a line <code>ActivationDepth = 5;</code> in beginner&#8217;s samples, thereby showing them that the setting is there and that they need to be aware of it.</li>
<li>Default string encoding seems to be <code>UTF-16</code> or <code>UCS-2</code>, probably the most useless encodings around, despite the Windows Kernel working with it. <code>UTF-8</code> would come in as a reasonable default, but with <code>UTF-16</code> half of your database is probably zeros, because even in non-english environments, there is still a lot of mostly ASCII-data to be stored (such as URLs, Email addresses, base64 encoded information, SHA-hashes, etc.). Also many languages have non-ASCII characters only sparingly, German being one example.</li>
</ul>
<p>I think it&#8217;d be really cool if the configuration interface was a little more explicit and would throw Exceptions instead of silently ignoring requests that cannot be fulfilled.</p>
<div class="tweetthis" style="text-align:right;"><p> <a rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=My+db4o+Wishlist+http%3A%2F%2Femphess.net%2F%3Fp%3D168" title="Post to Twitter"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter2.png" alt="Post to Twitter" /></a> <a rel="nofollow" class="tt" href="http://delicious.com/post?url=http://www.emphess.net/2010/04/14/my-db4o-wishlist/&amp;title=My+db4o+Wishlist" title="Post to Delicious"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a rel="nofollow" class="tt" href="http://digg.com/submit?url=http://www.emphess.net/2010/04/14/my-db4o-wishlist/&amp;title=My+db4o+Wishlist" title="Post to Digg"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.emphess.net/2010/04/14/my-db4o-wishlist/&amp;t=My+db4o+Wishlist" title="Post to Facebook"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.emphess.net/2010/04/14/my-db4o-wishlist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Simple Standalone Server for db4o as Windows Service</title>
		<link>http://www.emphess.net/2010/01/23/a-simple-standalone-server-for-db4o-as-windows-service/</link>
		<comments>http://www.emphess.net/2010/01/23/a-simple-standalone-server-for-db4o-as-windows-service/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 03:48:38 +0000</pubDate>
		<dc:creator>Christoph Menge</dc:creator>
				<category><![CDATA[db4o]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[EventLog]]></category>
		<category><![CDATA[Object Database]]></category>
		<category><![CDATA[OODBMS]]></category>
		<category><![CDATA[ServiceBase]]></category>
		<category><![CDATA[ServiceInstaller]]></category>

		<guid isPermaLink="false">http://www.emphess.net/?p=73</guid>
		<description><![CDATA[Download: db4oSimpleServer Lately, I have fiddled around with Versant&#8217;s excellent dual-license object database db4o a little and I think object databases are very neat. In fact, I read a few pages in PoEAA [Patterns of Enterprise Application Architecture] today, and here and there Fowler writes how cool object databases are. The Fowler knows! Well, anyhow [...]]]></description>
			<content:encoded><![CDATA[<p>Download: <a href='http://www.emphess.net/wp-content/uploads/2010/01/db4oSimpleServer.zip'>db4oSimpleServer</a><br />
<a href="http://www.emphess.net/wp-content/uploads/2010/01/solution.png"><img src="http://www.emphess.net/wp-content/uploads/2010/01/solution.png" alt="" title="Solution Layout" width="222" height="372" class="alignright size-full wp-image-75" /></a></p>
<p>Lately, I have fiddled around with Versant&#8217;s excellent dual-license object database <a href="http://www.db4o.com">db4o</a> a little and I think object databases are very neat. In fact, I read a few pages in PoEAA [Patterns of Enterprise Application Architecture] today, and here and there Fowler writes how cool object databases are. The Fowler knows!</p>
<p>Well, anyhow when you <a href="http://www.db4o.com/DownloadNow.aspx">download db4o</a> (sign up and go for the latest release) there is no standalone server application included. That makes perfect sense, because the server needs access to your domain model / data model dll. In an object database, <em>there are no tables</em>, but there are objects, so you have to compile them into the application that runs the actual db4o server. There is server <em>code</em> which handles practically everything that is tricky, but it&#8217;s in a dll so you&#8217;ll have to write a few lines to build an application out of it. I figured this would be a great time to write my first windows service and so I mashed up some code I found on the net. </p>
<p>I initially thought the VS 2008 designer would set up pretty much everything, but it turned out that things are a little more complicated.</p>
<h2>The Installer</h2>
<p>Since a service will run in a different manner, potentially using a different user account, etc. it needs to be installed first. There is a tool called <code>installutil.exe</code>, but using it is a little awkward. Also, you&#8217;d have to deploy it along your application. <a href="http://stackoverflow.com/questions/593454/easiest-language-to-create-a-windows-service">Matt Davis posted a cool guide on stackoverflow</a> and <a href="http://stackoverflow.com/questions/1195478/how-to-make-a-net-windows-service-start-right-after-the-installation/1195621#1195621">some additional information here</a> on how to write a windows service that is esentially able to install itself! </p>
<h3>Unexpected Features</h3>
<p>One of the most peculiar features is that -should you prefer to have your own event log instead of writing to the ApplicationLog- you have to search through a tree of installers, find the <code>EventLogInstaller</code> and modify it instead of simply adding a new one because the <code>ServiceInstaller</code> will come along with the <code>EventLogInstaller</code> as a child:</p>
<pre class="brush: csharp">
EventLogInstaller installer = FindInstaller(this.Installers);
if (installer != null)
    installer.Log = ServiceConfiguration.LogName;
</pre>
<p>We also need to take care of spawning the actual worker thread, but fortunately there is a <a href="http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase(VS.80).aspx">comprehensive guide on MSDN</a> explaining this.</p>
<h2>Using the Sample</h2>
<p>First things first: Of course, this is not <em>nearly</em> production-safe code! Also, I did not include the db4o dll&#8217;s because I&#8217;m not sure about the licence terms.<br />
<div id="attachment_74" class="wp-caption alignleft" style="width: 695px"><a href="http://www.emphess.net/wp-content/uploads/2010/01/install.png"><img src="http://www.emphess.net/wp-content/uploads/2010/01/install.png" alt="" title="Install" width="685" height="193" class="size-full wp-image-74" /></a><p class="wp-caption-text">The installer in 'action'. Note the Administrator prompt</p></div></p>
<ol>
<li>Download <a href='http://www.emphess.net/wp-content/uploads/2010/01/db4oSimpleServer.zip'>the sample</a>, extract</li>
<li>Download db4o, install</li>
<li>Copy <code>Db4objects.Db4o.dll</code> and <code>Db4objects.Db4o.CS.dll</code> from the db4o install directory to the samples&#8217; lib directory</li>
<li>Compile</li>
<li>Open an <b>Administrator</b> command prompt and find the sample&#8217;s <code>bin</code> folder. There is no feedback in case anything goes wrong (at best, the program crashes)</li>
<li>Call the install routine by executing <code>emphess.db4oServer.exe -install</code>. This will install the db4o server and the associated event log. The server will not be started automatically.</li>
<li>Head over to <code>services.msc</code> or your EventLog, where you <a href="http://blogs.msdn.com/helloworld/archive/2008/12/11/creating-an-event-log.aspx">should find a new entry!</a></li>
<li>Edit the configuration file, ready to run!</li>
<li>Don&#8217;t use this for anything production&#8230;</li>
</ol>
<h3>The App.Config</h3>
<p>The configuration file looks like this</p>
<pre class="brush: xml">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;configuration&gt;
  &lt;appSettings&gt;
    &lt;add key=&quot;UseLocalFile&quot; value=&quot;false&quot; /&gt;
    &lt;!-- &lt;add key=&quot;DatabaseLocalFileName&quot; value=&quot;irrelevant&quot;/&gt; --&gt;
    &lt;add key=&quot;DatabaseHost&quot; value=&quot;localhost&quot; /&gt;
    &lt;add key=&quot;DatabasePort&quot; value=&quot;52354&quot; /&gt;
    &lt;add key=&quot;DatabaseServerFileName&quot; value=&quot;C:/Development/db4oServer/db/server.db4o&quot; /&gt;
    &lt;add key=&quot;DatabaseUser&quot; value=&quot;test&quot; /&gt;
    &lt;add key=&quot;DatabasePassword&quot; value=&quot;test&quot; /&gt;
  &lt;/appSettings&gt;
&lt;/configuration&gt;
</pre>
<p>The <code>UseLocalFile</code> setting is meant for clients so you can easily switch between file-based and network-based configurations. Since <code>db4oServer.Shared</code> contains a small class that holds this configuration data, you can easily reuse the code in a different app, e.g. in the client.</p>
<h3>Todo-List</h3>
<p>There are some things I&#8217;d like to add over the next weeks, so I put the list here to give me some &#8216;pseudo-extrinsic motivation&#8217;&#8230; (yes, I like complicated words)</p>
<ul>
<li>Simple sample client</li>
<li>Out-of-band data for backup, defragmentation commands, etc.</li>
<li>Tests / Benchmarks</li>
</ul>
<p>I hope you have any use for this.</p>
<div class="tweetthis" style="text-align:right;"><p> <a rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=A+Simple+Standalone+Server+for+db4o+as+Windows+Service+http%3A%2F%2Femphess.net%2F%3Fp%3D73" title="Post to Twitter"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter2.png" alt="Post to Twitter" /></a> <a rel="nofollow" class="tt" href="http://delicious.com/post?url=http://www.emphess.net/2010/01/23/a-simple-standalone-server-for-db4o-as-windows-service/&amp;title=A+Simple+Standalone+Server+for+db4o+as+Windows+Service" title="Post to Delicious"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a rel="nofollow" class="tt" href="http://digg.com/submit?url=http://www.emphess.net/2010/01/23/a-simple-standalone-server-for-db4o-as-windows-service/&amp;title=A+Simple+Standalone+Server+for+db4o+as+Windows+Service" title="Post to Digg"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.emphess.net/2010/01/23/a-simple-standalone-server-for-db4o-as-windows-service/&amp;t=A+Simple+Standalone+Server+for+db4o+as+Windows+Service" title="Post to Facebook"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.emphess.net/2010/01/23/a-simple-standalone-server-for-db4o-as-windows-service/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

