Database for storing heterogeneous "message" objects

Michal Wallace sabren at manifestation.com
Sun Feb 6 22:01:23 EST 2000


Jason Stokes wrote in message ...

>The Python standard relational database API doesn't quite fit this domain
>because the structure of such a database isn't quite tabular.  Although the
>messages will have certain mandatory headers like from, subject etc. in
>common, individual messages will also have optional headers that aren't
>defined for all messages.  I want to allow queries on optional headers --
if
>a header is defined for a message, any selection rule based on that message
>will be applied to it, otherwise the test automatically fails.



Hey Jason,

Sounds like you want an object oriented database...   dunno how to
talk to any of those from python.. but you can sort of simulate this
without abandoning the RDBMS model by using 1:1 joins.. for example:

create table message (
    ID int not null auto_increment primary key,
    messagetype : varchar(32) -- (or whatever)
    whoFrom varchar(50),
    whoTo varchar(255),
    subject varchar(255)
    content text
)

create table special_message1 (
    ID int not null auto_increment primary key,
    messageID int not null unique,
    specialfield1 varchar(255)
)

create table special_message2 (
    ID int not null auto_increment primary key,
    messageID int not null unique,
    specialfield1 varchar(255)
)


#########

or... if you have a bunch of different fields you could do this:

create table message (
    ... same as above ...
)

create table specialfield (
    ID ...
    specialfield varchar
)

crate table message_specialfield (
    ID ...
    messageID ...
    specialfieldID ...
    value varchar
)

.... depending on how smart your RDBMS is, finding a message
might take several queries, but you could encapsulate all of it
in a generic class...


-Michal Wallace
sabren at manifestation.com






More information about the Python-list mailing list