Attachments in Programming

By ecliptic

I am wanting some advice on getting started on an application that has to take attachments. Basically, I have an application that creates/pulls data from MS SQL Server. With this data, the user can add attachments that are associated with it. I am wondering what is the best (I know that’s subjective, but opinions are what I am asking for) route to take for accomplishing this task. Here are my thoughts:

1) In the database, have a column with links separated by a semicolon.

Pro – Small storage on the database
Con – If the file is moved/modified, the database had to be updated at the same time. Also, processing time for going through the list of attachments.

2) In the database, just have a column that actually points to the attachment itself, letting SQL Server load the attachment internally (not sure if that’s possible, but I know that Wiki’s do it). Basically, it would be like inserting the attachment into the database, and letting SQL Server do it’s thing.

Pro – Easy to code (hopefully)
Con – Not sure about the security… could load a malicious file…etc..

Any thoughts would be great! Thanks all!

3 Responses to “Attachments in Programming”

  1. ecliptic Says:

    Just thought I’d post an update. I decided against storing data into the database despite the fact that it would be 100x easier… I decided to build my own file manager class to handle storage of the files uploaded to the system and store references to the files in the database.

    The reason I decided to do that was simply because I did not want to keep an open connection to the database when people are uploading/downloading files to the database. Probably a DUH answer to most developers, but ahh well… live and learn. My scheme was as follows:

    1 – Validate file extension and size
    2 – Insert record into database declaring an attempt to upload a file to the database
    3 – Attempt to upload file leaving server location directory field blank
    4 – Update database if file was unsuccessful/successful (update server location accordingly)

    I did it this way so that I can keep up with failed attempts vs successful attempts of uploading files to our system. This strategy also keeps a cache of the data inserted into the database in case a file was unsuccessful uploading, but the other data was inserted successfully.

  2. ecliptic Says:

    Oh.. and another update. Since I’m a huge advocate to not deleting data from a database… I decided to add an “Active” flag. :D

  3. Marinasportsarena3426$anchor$basketball Betting,final Four,final Four Betting,final Four Gambling,final Four Sports Book,final Four Sportsbook,march Madness,march Madness Betting,march Madness Gambling,march Madness Sports Book,march Madness Sportsbook,nc Says:

    Marinasportsarena3426$anchor$basketball Betting,final Four,final Four Betting,final Four Gambling,final Four Sports Book,final Four Sportsbook,march Madness,march Madness Betting,march Madness Gambling,march Madness Sports Book,march Madness Sportsbo…

    Marinasportsarena3426$anchor$basketball Betting,final Four,final Four Betting,final Four Gambling,final Four Sports Book,final Four Sportsbook,march Madness,march Madness Betting,march Madness Gambling,march Madness Sports Book,march Madness Sportsbook…

Leave a Reply