views:

52

answers:

1

Hey all, I'm learning Doctrine + Symfony and I may have chosen too complex a data model for my own good.

Here's an overview:

  • Users create Gizmos.
  • There are 5 Modules to choose from. Users cannot define new ones, only instantiate them.
  • A Gizmo has any number of Instances in any order. An Instance has one Module ID.
  • Instances are configurable, but the available settings depend on the Module ID. A Foo Module may require an integer and a string, while a Bar Module may require a arbitrary-length list of strings.
  • Each Instance of a Module can be provided different setting values (a Gizmo that has two Instances of Foo Modules may set (5, "baz") on one and (100, "frob") on the other).

So I've got an Instance table with an Instance ID, a Gizmo ID, a Module ID, and an Order.

And I've got a table for each type of Module, keyed on Instance ID, representing the settings for that Instance. The FooModule table has Instance ID, an integer, and a string.

You can see how this is fundamentally an object-oriented schema. How can I represent these relationships in Doctrine's YAML? Or am I going about this the wrong way?

A: 

All right, I think I've found the answer using Doctrine's "concrete inheritance" feature. Here's somebody's explanation of the setup.

Jem Garblman