Search code examples
ravendbdocument-databaseobject-oriented-database

What is the difference between object-oriented and document databases?


What is the difference between object-oriented and document databases?

I didn't use object-oriented databases, but when I use document database (RavenDb) I store and read usual object-oriented classes without problems.


Solution

  • I went from db4o (OODB) to RavenDB (document DB). The big difference, that I found, is that object DBs store the full objects, and when an object gets stored with another object within it, that sub-object is stored in full and it's the latest version of that object. With a document DB, objects are still stored, but they're organized differently. An aggregate/root object will store parts of a sub-object so that the aggregate/root object is self-contained. When you retrieve the root object, you're not reaching out and grabbing objects that are related to it.

    An OODB would store a Team this way:

    TeamName
    City
    List<Player>  // The entire player objects would be stored here
    

    A document DB would store a team this way:

    TeamName
    City
    List<string> PlayerNames
    

    PlayerNames would be stored here, because that's all the team object needs.

    RavenDB has a good explanation of the theory of document DBs here:

    http://ravendb.net/docs/theory/document-structure-design