Algorithm for Labels like in Gmail

Rodolfo rhcarvalho at gmail.com
Sat Jun 10 22:04:06 EDT 2006


Hi George,

George Sakkis wrote:

> Google for "many-to-many relationships". In short, you have two entity
> classes (say emails and labels) where each instance of one entity may
> be associated to zero or more instances of the other entity. In
> databases you implement this by having three tables, one for each
> entity and one for their association:
>
>    Email     RelEmailLabel     Label
> ----------   --------------    ---------
> ID        <--- EmailID          ID
> subject        LabelID --->     name
> ...                             ...
>

Ok, but how can I keep my Relationship Table out of bugs, bad data?!
I wonder how i'll control the following:
1st) Given an generic email, in which group(s) is it contained?
2nd) Given a group, which Emails/contacts does it contain?

I don't have much expererience with databases (yet).
Will the pysqlite work with ease? Because I don't mean to make a big
big program, just something very simple for my personal use.

>
> Then you can associate mails to labels by joining all three tables
> together on the IDs. Of course you can implement this in memory as well
> but you should probably want to store them in some persistent area
> anyway, so an rdbms the way to go. Sqlite (with pysqlite) would meet
> your needs just fine.

I'll google for this module tomorrow and try to learn something about
it.
I plan to post the code I manage to write.

BTW which is the best way to store all those data files? Plain text
files? Some kind of binary file? or what?

Thank you once again,

Rodolfo




More information about the Python-list mailing list