Class structure is something like this..

  +------+         +------------+              +-------------+
  |  Bar |--------o|  Relation  |o - - - - - - |     Foo     |abstract
  +------+         +------------+              +-------------+class
  |  id  |         |   attrs    |o             |      id     |
  | name |         +------------+ \_________   |     name    |
  +------+                         \        \  +-------------+
                                    \        \___^_____    ^
                                     \           |     \   |
                                      \ +------------+  +-------------+
                                       \|  NoisyFoo  |  | ColouredFoo |
                                        +------------+  +-------------+
                                        |     id     |  |     id      |
                                        |  decibels  |  |    color    |
                                        +------------+  +-------------+

Bar has many Relations
NoisyFoo has many Relations
ColouredFoo has many Relations
Bar many-many NoisyFoos
Bar many-many ColouredFoos

(Bar many-many Foos?)


NoisyFoo and ColouredFoo inherit from Foo

It actually gets more complicated than this because
- Bar and Foo both inherit from a base object.
- All objects have a unique id are connected via Relation objects
- The relation object also contains levels of inheritance

I want to be able to do queries like

1) Given a Bar, find all related Foo objs
2) Given a NoisyFoo or Coloured Foo, find all related Bars
3) For all bars with name matching "%str%" find all NoisyFoos with decibels > 
'100'

Im not sure whether it would be better to
a) retain Foo, NoisyFoo and ColouredFoo as a 3 separate tables,
b) flatten to 2 tables, so NoisyFoo and ColouredFoo get their own name column
c) flatten all Foos to 1 Foo table and create a Type column to differentiate.


Questions:

 Is it possible to create Foo, NoisyFoo and ColouredFoo as separate tables (a), 
then create corresponding DBIx proxy classes for them in such a way that when I 
create a new NoisyFoo row, the 'name' value is automatically entered into the 
Foo table? And when I retrieve the row it is automatically read in from the Foo 
table?


If I were to flatten to 1 table per subclass (b), how would I write a 
relationship that enabled me to perform query (1) above; find all Foos for a 
given Bar.
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender does not 
intend to waive confidentiality or privilege. Use of this email is prohibited 
when received in error.

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to