Lou Arnold wrote:
> After I read all the posts, I almost rolled on the
> floor with laughter. I AM A NEWBIE. I couldn't
> believe that you all let your egos get in the way.
Sorry about that.
You may like to read up the history of some of the
previous discussions of the same people in this group
and in other newsgroups to understand why the flames
rise high so quickly.
I think the discussions are a very nice proof that
object oriented programming and relational databases
do not match.
> And by the way, the example:
> ClasS Person{
> Person son
> ....
> }
> is truely NONSENSE.
I am afraid you did not understand what I was trying
to say.
You wrote: "PersonX is the son of PersonY. The OODB
can't know this without somehow being told."
I gave you exactly what you wanted.
The simplest way in OO to express that personX is the
son of personY goes like this:
(1) One class and three lines of code
-------------------------------------
class Person{
Person son;
}
Person personY = new Person();
Person personX = new Person();
personY.son = personX;
Now your objects in the memory of your programming language
"know" that "personX is the son of personY", right?
To tell the object database also, all you have to do is
store personY:
(2) One line to store an object and all references
--------------------------------------------------
database.store(personY);
No more.
Object databases persist by reachability, so the attached
personX would be stored along with personY.
Assuming the same prerequisites of (1), here is what you
would have to do with one of todays relational databases,
using SQL:
(3) SQL
--------------
CREATE TABLE Person
(Id INTEGER, Name VARCHAR(100), Son INTEGER);
INSERT INTO Person
(Id, Name, Son)
VALUES
(1, 'personY', 2);
INSERT INTO Person
(Id, Name)
VALUES
(2, 'personX');
Assuming you are using an OO language like Java, you could
not execute the three SQL statements like above, you would
need to put them into strings and call a couple of JDBC
methods. For example:
Statement statement = connection.createStatement();
String sql = "INSERT INTO Person (Id, Name, Son) "
+ "VALUES (1, 'personY', 2)":
statement.execute(sql);
Furthermore I made things very easy by using my own keys,
'1' and '2'. In a real multiuser database, you would
either need a local key generator, that makes sure that
your keys are unique or you would use an autoincrement
column and fetch the key, after your insert, for every
row that you insert (slow).
Furthermore you would have to extract the data from your
objects first and then put them into your SQL string or
into parameters.
The point I am trying to make with the above:
Object databases provide tighter integration with object
oriented languages, so they reduce development time and
cost. Your code is more maintainable because it is less
code overall and because it is typesafe OO code, without
embedded strings. Futhermore it executes a lot faster.
Of course this only holds if you use an OO language in the
first place.
Certainly one would not model "son" this way in a real
usecase:
class Person{
Person son;
}
Some possibilities:
class Gender{
static final Gender MALE = new Gender();
static final Gender FEMALE = new Gender();
}
(1)
class Person{
Person mother;
Person father;
Gender gender;
}
(2)
class Person{
List children;
Gender gender;
}
(3)
class Person{
Person mother;
Person father;
List children;
Gender gender;
}
(4)
class Person{
Person[] parents;
Gender gender;
}
Again the relational camp will come along arguing:
"See, because object orientation does not follow sound
relational principles, there is not one single correct
normalized way to do it."
This argument forgets two major points:
(1) If the application uses an object oriented language,
the class model is created anyway, correct or not, one
way or the other. Objects will exist anyway, correct or
not, in one of the above flavours. Relational databases
will not remove the objects.
(2) Object database vendors do not try to prove that
object oriented programming is correct and they do not
need to. Mainstream has gone that way. More than 50%
of all new programming projects either use Java or one
of the .NET dialects (C#, VB.NET, ASP.NET).
Object database vendors simply take what's there in
the object oriented language and store it in the most
efficient way.
--
Carl Rosenberger
Chief Software Architect
db4objects Inc.
<a rel="nofollow" style='text-decoration: none;' href="http://www.db4o.com" target="_blank">http://www.db4o.com</a>
>> Stay informed about: Help Understanding OODBMS'