I am experimentation with db4o like a data store, to get a handle on it I decided to build myself an easy problem monitoring web application (in ASP.Internet MVC). I have found db4o to become excellent when it comes to rapid development, specifically for small applications such as this, and in addition it negates the requirement for an ORM.

However, getting originate from a SQL Server/MySQL background I am a little unclear about the way i ought to be constructing my objects if this involves associations (or possibly I simply don't correctly comprehend the way object databases work).

Here's my simple example: I've just two model classes, Problem and Person.

public class Issue
{
    public string ID { get; set; }
    public string Title { get; set; }
    public string Description { get; set; }
    public DateTime? SubmittedOn { get; set; }
    public DateTime? ResolvedOn { get; set; }
    public Person AssignedBy { get; set; }
    public Person AssignedTo { get; set; }
}

public class Person
{
    public string ID { get; set; }
    public string Name { get; set; }
    public string Email { get; set; }
    public string Password { get; set; }
}

The ID qualities are simply GUID strings produced through the .Internet Guid.NewGuid() assistant.

So here's the way i initially thought the applying works please ignore any security concerns etc and assume finances a couple of Person objects saved within the database:

  1. User logs in. Query the database for that Person which fits the account information, and store his/her GUID id like a session variable. Redirect to application desltop.
  2. Drenched in user produces a brand new problem ticket, choosing the consumer to assign it to from the drop-lower list. They complete another particulars (Title, Description etc), after which submit the shape.
  3. Query the Person objects within the database (by their GUID ID's) to obtain an item representing the drenched in user and something representing the consumer check in continues to be designated to. Produce a new Person object (populated using the published form data), assign the Person objects towards the Issue object's AssignedBy and AssignedTo qualities, and store it.

This could mean I've two Person objects saved against each Issue record. But what goes on basically update the initial Person—do all of the saved references to that particular Person within the various problem objects update, or must i handle that by hand? Are they references, or copies?

Will it be better/more effective to simply store a GUID string for that AssignedBy and AssignedTo fields (as below) then look in the original person according to that every time?

public class Issue
{
    public string ID { get; set; }
    public string Title { get; set; }
    public string Description { get; set; }
    public DateTime? SubmittedOn { get; set; }
    public DateTime? ResolvedOn { get; set; }
    public string AssignedByID { get; set; }
    public string AssignedToID { get; set; }
}

I believe I am just stuck in in certain manner of thinking that is confusing me. If a person could explain it clearly that might be most useful!

Object-Databases viewed exactly the same semantics as objects in memory. The general rule is: It really works like objects in memory. Object databases store references between your objects within the database. Whenever you update the item, that object is updates. And when you've got a mention of the that objects, the thing is the transformed version.

Inside your situation, the Problem-objects make reference to the individual object. Whenever you update that individual, all Issues which make reference to it 'see' that update.

Obviously, primitive types like int, strings, longs etc are handled like value objects and never a reference objects. Also arrays are handled like value objects in db4o, what this means is a array is saved along with the object and never like a reference. Anything else is saved like a reference, even collections like List or Dictionaries.