Thanks Dan, interesting example:

> Parent
> - parent_id  PK
>
> LeftChild
> - leftchild_id  PK
> - parent_id  PK,FK
>
> RightChild
> - rightchild_id  PK
> - parent_id  PK,FK
>
> ChildCombo
> - childcombo_id  PK
> - rightchild_id  FK
> - leftchild_id  FK
> - parent_id  FK

I agree that you do not need a unique ID but you can do the same if
you have one. In web2py this is doe under the hood:

db.define_table('parent',
             db.Field('name'))
db.define_table('left_child',
             db.Field('name'),
             db.Field('parent',db.parent))
db.define_table('right_child',
             db.Field('name'),
             db.Field('parent',db.parent))
db.define_table('child_combo',db.Field('name'),
             db.Field('left_child',db.left_child),
             db.Field('right_child',db.right_child),
             db.Field('parent',db.parent))

Note that I do not define the ID but it is there and handled for you.
You can make "name" unique using validators.

I agree that having the ID does not help you here but if in the future
you decide that these children can have an additional attributes and
you can have multiple left_child with same parent and same name but
different attributes in your case you have nightmare. With the unique
ID you do not need to change your database schema but only add those
attributes to one table and your data will migrate.

Massimo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to