On Friday 22 May 2009 23.00:05 Werner F. Bruhin wrote:
> What do you want to do with the autoincrement column?  Often these are
> used for primary keys, which in turn get used as foreign keys.

I want to use the id as filename; the table will cache some info that comes 
from the file.  Using it as a filename directly has several advantages:
 * I don't have to care about a unique filename, since the db already takes 
care of that.
 * I don't have to create an additional column with the filename.

Obviously, I can just first create the file with a temp filename, but I'd 
like to avoid this additional step if it's possible.  Less code == fewer 
bugs.  And I hoped that using the id from the beginning would be easily 
possible.

Right now, I'm undecided if I should just drop portability and fetch the 
next value from the mytable_id_seq that postgres has generated for me with 
the autoincrement columns (from what I understand, even if I declare the 
column autoincrement, if I set the id manually it will Just Work(tm) like it 
should or if I should go the temporary filename route.  I'm leaning towards 
the former because I probably will drop portability at some point in any 
case, since PostgreSQL just has too many cool features waiting to be used 
:-)

(And no, I'm not going to use blobs and store the file as a large object in 
the db.  Relational databases are not made for this, and besides it makes 
the db harder to maintain because db dumps get huge or the blobs have to be 
backed up separately, and debugging is harder because I can't use shell 
tools to get at the file data.)

(So you see, I'm not trying to build foreign keys by hand or any such thing.  
I actually know relational databases quite well, it's just my knowledge of 
SQLAlchemy and Python which is lacking.)

thanks
-- vbi

-- 
Alle Wirksamkeit ist stärker am Mittelpunkt als gegen die
Peripherie zu. Raum zwischen Mars und Jupiter.
                -- Goethe, Maximen und Reflektionen, Nr. 1336

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to