#1 2010-10-02 13:21:56

migajek
Member
Registered: 2010-10-01
Posts: 89

Many to many / one to many relations handling?

Hi,
is there any example of handling one to many (has/belongs) and many to many relations?

thanks,
migajek

Offline

#2 2010-10-03 08:54:19

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,240
Website

Re: Many to many / one to many relations handling?

Not yet such example.

You'll have to do it manually, with relational tables:

type
  TSQLOne = class(TSQLRecord);
  TSQLTwo = class(TSQLRecord);

  TSQLMany2Many = class(TSQLRecord)
  published
    One: TSQLOne;
    Two: TSQLTwo; 
  end;

Then populate TSQLMany2Many with some IDs in One or Two properties (not pointers to objects, but IDs of TSQLOne or TSQLTwo).
Then query for all linked items with OneFieldValues() method.

The framework create indexes for such properties.
So the result will be very fast.

I'll try to implement direct one to many or many to many properties creations, directly in the main table. I don't like the collection-oriented way of tiOPF. I'll try to find another way of declaring those.
If you have any idea/preference, feel free to post here!

Offline

#3 2010-12-14 06:45:10

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,240
Website

Re: Many to many / one to many relations handling?

"Has many" is now integrated into the framework.

See http://synopse.info/forum/viewtopic.php?pid=653

Offline

Board footer

Powered by FluxBB