Re: S.O.D.A. database Query API - call for comments

From: Carl Rosenberger <carl_at_db4o.com>
Date: Tue, 8 May 2001 21:41:50 +0200
Message-ID: <9d9i7n$3j4$03$1_at_news.t-online.com>


mikito Harakiri wrote:
> Ok, let object Car contain Wheel (4 fields, actually:-). How exactly would  I
> find a Car given a Wheel; what indexes would I use? (Note that sql folks  are
> eager to provide exact sql statements -- I would like to see the code for > objects either:-)

This is the "right-way-around" in a declarative query to an object database. Note that declarative queries and object navigation are beautifully complementary:
- navigation in the programming language finds members of objects - declarative queries constrain objects by their members

Code according to the current S.O.D.A. spec:

// your class model

class Wheel{
}

class Car{

   Wheel[] wheels;
}

// you have a given ObjectContainer to query against:
// and a given wheel

ObjectContainer db;
Wheel myWheel;

// get a new query object

Query carNode = db.query();

// constrain it to be of class car

carNode.constrain(new Car());

// add a subnode for wheels

Query wheelNode = carNode.getSubNode("wheels");

// use your given wheel to constrain this subnode
Constraint wheelConstraint =

    wheelNode.constrain(myWheel);

// specifiy identity comparison

wheelConstraint.identity();

// get the result set

ObjectSet res = carNode.execute();

// The same code again in
// shorthand chained uncommented notation:
Query carNode = db.query();
carNode.constrain(new Car());
carNode.getSubNode("wheels").constrain(myWheel).identity(); ObjectSet res = carNode.execute();

Your question "what indexes would I use?" only needs to be answered for relational databases. We are using objects. There is no need for keys to join objects.

Kind regards,
Carl

---
Carl Rosenberger
db4o - database for objects - http://www.db4o.com
Received on Tue May 08 2001 - 21:41:50 CEST

Original text of this message