Query Children

Dec 5, 2010 at 6:28 PM

Hello,

how is it possible to query the children of a class, for example, i have:

TCustomer = class
    Name: String;
    Budget: Decimal;

    List<TProduct> Products;

end;

How can i here Query first a Customer with Name "x" and then within this all the products?

 

Dec 5, 2010 at 9:54 PM

As far as I understand, the system will take care of it. The Product data will be stored in the Product table automatically.

If you retrieve your Customer, you will get the List of Products automatically too. You need to create a Customer-Table too...

Of cause its also possible, to just store a Guid (or other Id) in your List and retrieve the related Products data via their Keys or have a relational key inside the Products to point to the Key of the Customer (thats more the classic database approach - makes sense if you dont need the Products all the time).

Dec 6, 2010 at 8:42 AM

Thank you very much, that's really an Object Oriented Database!

Coordinator
Dec 6, 2010 at 1:06 PM

Yes. The main decision to make is the strategy for storing the object graph. If "Product" is a simple class and is always a child of Customer, then you can provide a definition for Customer and all products are simply serialized whenever the Custom class changes.

More likely, products might be a little more independent and while they reference a customer, if you wish to be able to update them independently of the customer, then you can provide a definition for Product. What this will result in is instead of a list of Products being serialized for the Customer, a list of keys for Products will be serialized, and then the product itself will be independently managed as a table by Sterling.