David McNab | 28 Apr 10:42
Picon

emulating 'nested tables'

Hi,

I've prototyped a database using Metakit (which allows tables to have
nested tables as columns), and want to migrate it over to use SQLObject.

Consider:

  class Foo(SQLObject):
    someattr = IntCol()
    otherattr = StringCol()
    things = MultipleJoin("Thing")

  class Thing(SQLObject):
    attr1 = BoolCol()
    attr2 = StringCol()
    foo = ForeignKey("Foo")

This will give an effect similar to 'nested tables', since the '.things'
attribute of any Foo object will yield a list of Thing records.

But if the database grows to having tens of thousands, even millions of
rows in each table, then accessing '.things' could prove pretty slow.

Another option is to look into dynamic creation of tables, where for
each Foo object I create a dynamic Thing-like class. But I don't know
how I could get the convenience similar to just fetching '.things'
attributes of Foo objects to access each dynamic table.

Can anyone suggest the best way to get decent scalable performance with
this scenario?
(Continue reading)

Oleg Broytmann | 28 Apr 14:06
X-Face
Picon
Favicon

Re: emulating 'nested tables'

On Mon, Apr 28, 2008 at 08:43:41PM +1200, David McNab wrote:
>   class Foo(SQLObject):
>     someattr = IntCol()
>     otherattr = StringCol()
>     things = MultipleJoin("Thing")
> 
>   class Thing(SQLObject):
>     attr1 = BoolCol()
>     attr2 = StringCol()
>     foo = ForeignKey("Foo")
> 
> But if the database grows to having tens of thousands, even millions of
> rows in each table, then accessing '.things' could prove pretty slow.

   See my previous message to the list about SQLMultipleJoin.

> Another option is to look into dynamic creation of tables, where for
> each Foo object I create a dynamic Thing-like class.

   Do you mean dynamic creation of *rows*?

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
(Continue reading)


Gmane