I have no idea if I will do it right, or something is completely stupid.
I have a file system that will contain a bunch of image files. These are large images of variable size cards. I use my database to perform spatial queries on them.
Basically, all I want to do is the ability to add image information (name, directory and spatial information) to the database and delete the image from the database (records in all tables along with an external file associated with this record). I know how to delete all records, but not external data. I do not want to embed images in the database as a binary blob, because I often use external tools for files.
Basically, my database only tracks the file name and directory along with the spatial data associated with the file.
How to delete a file from the file system when I delete a record from the database?
Am I even right about that? Is it more common to embed an image in a database as a binary block? (The overhead of copying the data around makes this implausible to me, and there should be a better way.)
I hope this does not matter, but I use postgre as my SQL database on Linux.
EDIT: my current strategy is a shell script that handles image deletion. During the shell script, it forces the transaction file to delete all database records associated with the image, preserving the full path of the file to a flat text file. If the transaction is successful, I delete the image in a flat file. It is reasonable? Is there a better way?
source share