J
Jochen Theodorou
Daniel said:I think *you* have it backwards. All relational models can be expressed
with an object graph but not all objects graphs can be expressed with a
relational model. Which is why I said than an OODB *can* be relational,
not that all OODBs are inherently relational.
I am really for OODBs, but I can't agree with you here. A simple class
can be seen as a data container. In that regard it is really not more
than a table with the attributes being the columns and each instance is
a row. But that is not really an object. That is a data based view on an
object that every union based type fulfills. It gets really object
oriented when you add inheritance here. And then the mapping is not so
direct anymore. (Note: you don't really need classes for this, but I
will use them for better understanding)
So for example I have class A with an attribute id and a class B with an
attribute email and a class C that has the parents A and B and has an
attribute name. Now what do we do? Make a table for A, one for B and one
for C, or one table for all of them? Even if you simplify this to single
inheritance, you still have that problem.
When I for example use one table per class and link these tables
together to represent the inheritance, then I get a massive problem in
my queries. Because If I query on C I might have to query on A and B as
well.
When each subclass table contains all data of that class and the super
classes, then a query on C is done on only one table. But the relation C
"is a" A is not represented in this. C could be a class completely
unrelated to A, which means we reduced it to the data holder type again.
It is the same when you store A,B and C in the same table. Only that you
then need additional logic based on the class for the empty entries.
So I think there is a part of the object system that is equal (bijective
projection) to a part of the relational system, but in both cases not
the whole model is covered.
So if your objects can be mapped nicely to an relational database, then
most possibly you are using a not so object oriented part of your object
system.
Then two more things...
* OODBs are restricted to one language only:
db4o is an example against it. Not only covers it the Java Platform, it
covers also the .Net languages. And of course an object stored from .Net
can be used in the Java Platform as normal object then. You could say
that .Net and the Java Platform are using more or less the same kind of
class structure (single inheritance for example), but then it is all a
question of doing the mapping, or not?
* OODBs don't allow me to access the data in a different way than my
original object modell:
Well, is there really a limitation that prevents a OODB from saying that
certain attributes of an class are really the properties of another
class? This way I don't need to always create a full object.
* OODBs have roots and I have to use these roots to navigate to my real
object:
db4o for example allows you to query on a per class base, so each
instance can be root. You need other objects only for joins. see S.O.D.A.
* OODBs are hierarchic:
I think they can be, but they don't have to. There is also for example
the network model. In fact it might also use parts of the relational
model. I think the queries used for the OODB are giving a hint how it is
represented inside, but in general it is an implementation detail. So an
object graph can be understood as directed graph, and of course I can
define a a minimal spanning tree on the subgraph that is transitive
reachable from my selected root. But the root is more or less arbitrary,
and the graph might not be connected enough for just one tree.
* object-relational databases are OODBs:
As I tried to show with the subclass example there are parts of the
object model that don't fit so well in the relational model and there
are parts of the relational model that don't fit so well in the object
model. So in the end you get only a part of both worlds. Up to you to
decide if that is good enough
* there are much less tools for OODBs:
that's right, no use to say more.
I also think that the relational algebra is more advanced than
everything an OODB could provide. I think most OODB queries will for
example have a problem with operations like getting the maximum/minimum
of something, or subtracting one attribute from the other and such
things. So especially in cases of reporting OODBs are not that good, not
unless you do many of the operations outside the database system.
bye blackdrag