Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6011689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:17:46+00:00 2026-05-23T02:17:46+00:00

I have no idea if I’m even going about this the right way or

  • 0

I have no idea if I’m even going about this the right way or I’m going something completely stupidly.

I have a file system that will hold a bunch of image files. These are large map images of variable size. I am using my database to do spatial queries on them.

Basically all I want to do is be able to add an image’s information (name, directory, and spatial info) to the database and delete an image from the database (the records in all tables along with the external file associated with that record). I know how to delete all the records but not the external data. I do not want to insert the images into the database as a binary blob because I will frequently be using external tools on the files.

Basically my database is only tracking the file’s name and directory along with the spatial data associated with the file.

How do I delete a file from the file system when I delete the record from the database base?

Am am even going about this correctly? Is it more normal to insert the image’s into the database as a binary blob? (The overhead of copying the data around makes this implausible for me and there must be a better way.)

I’m hoping it is irrelevant but I’m using postgre as my SQL database under Linux.

EDIT: My current strategy is use a shell script that handles the deletion of an image. During the shell script, it makes a transaction file to drop all the database records associated with the image while saving the file’s full path to a flat text file. If the transaction was successful, I then delete the image in the flat file. Is this sensible? Is there a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:17:46+00:00Added an answer on May 23, 2026 at 2:17 am

    Your “current strategy” sounds like the standard approach to me: delete from the database and if that succeeds (and that is a big “if”), delete the corresponding image file. You’d probably want a sanity checker to make sure you’re not accumulating cruft though, just a simple comparison of the database and the file system to make sure they agree with each other.

    You don’t need to store the images in the database, the file system is quite good at handling files and it will probably be a lot more convenient to have them in the file system. And, as noted by David Ryder below, the file system will almost certainly be notably faster for dealing with large image files than the database: file systems are pretty good at dealing with files, that’s what they do.


    UPDATE: If you need this to be really quick then you could try doing the file deletions with a cron job. Once every couple hours (or day or whatever works), a cron job could compare the database with the file system and delete any stray images. This would make mass deletes from the database easier: you’d be able to do a DELETE FROM whatever WHERE ... to kill off multiple entries and then your janitor would come along later to clean up the leftover images.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone have idea on this? Linker errors are way out of my wheelhouse, especially
I don't have idea about overlay.I am stuck at this point.I am integration one
Anyone have idea about how to bind Boolean in sqlite with objective - c.
I missed my workspace in which I was working. Any one have idea about
I have an idea for a functional programming language design that makes heavy use
I have no idea why this is happening. The error I get is the
Can any body have idea how to consume php soap web service that have
In fact I have Idea about the exception handling. But while facing the interview
i want to implement comet in php... i have idea about how ajax works
Hello Can Any one have idea about below code and its related error. code:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.