From: Ian B. <ia...@co...> - 2005-01-12 04:44:48
|
Jeremy Cowgar wrote: > I have about 9 tables that all accept notes. So, I created one note table > that looks something like: > > CREATE TABLE notes ( > id int unsigned auto_increment primary key, > obj_type int, > obj_id int unsigned, > title varchar(80), > body text); > > In each object I have a .OBJ_TYPE field that has a 1, 2, 3, etc... Then, when > a note is added, I use both the .OBJ_TYPE and the object id to insert into > the notes table. This gives me 1 table, and also when searching for > information this is a great plus. > > I think you can see the problem already. How can I relate to that table in my > 9 different objects? There needs to be an additional condition on my link. Is > this possible? If not, is my database design bad? You'll have to hand-code it, but that's not that big a deal. Do something like: class SiteSQLObject(SQLObject): def _get_notes(self): return Note.selectBy(obj_type=self.obj_type, obj_id=self.id) class FirstTable(SiteSQLObject): obj_type = 1 And so on. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |