[SQLObject] Enums, lookup tables, and python classes...
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Bud P. B. <bu...@si...> - 2003-05-30 08:53:58
|
On Fri, 30 May 2003 00:33:00 -0400 Edmund Lian <el...@in...> wrote: > 7. I don't use enums at all. For table driven applications, I use > primary keys coupled with foreign key constraints. This allows you to > change the allowed values of a column by varying the contents of another > table. This is one argument against using synthetic primary keys. But > using synthetic primary keys is still OK so long as unique columns can > be specified, and the foreign key constraint can take the name of a column. I've used the above pattern a lot and very successfully so. But I believe also that it is a pattern that is limited strictly to the relational domain--so I've been pondering how to deal with this in a more object-oriented way. And here is what I've come up with so far: I believe the "lookup tables" or whatever you call them should behave as Python Classes to the Application programmer. They may of course still be stored in the dbms (class attributes instead of instance attributes...). If this sounds interesting, I'll keep you posted on my progress in this.. |