locked
Which one is advisable? RRS feed

  • Question

  • User2129316869 posted

    I am trying to create an upload code in my project and am confused after reading Mike's Article on it on whether to use File to store or database to store. Please every contribution as regards to this is highly appreciated. Thanks

    Saturday, June 7, 2014 10:11 AM

Answers

  • User379720387 posted

    One of the points I recall from previous discussion is that you may not have access to the file system once your application is deployed.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 7, 2014 10:28 AM
  • User-1716253493 posted
    Simple way is storing file in the web then store filename or path to database. You can create link directly to the file when you want to download. If you store it in database, you need to extract the file using handler.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 7, 2014 10:36 AM
  • User-821857111 posted

    The main justification for storing files in the database is security. Only people with access to the database can do anything with the files. So you are less likely to have e.g. images "disappear" (get deleted / renamed) by someone with acess to the file system on the server eg via FTP. You can also control access to static files via a handler which can check if a user is authenticated/in the correct role before serving the file. Backups are simpler too. You don;t have to worry about implementing a separate backup regime for your files.

    The downsides to database storage include database backups being larger and taking longer. Some databases are restricted in total size. For example, SQL Compact can only reach 4GB as can Sql Express 2005 databases. More modern SQL Express database can go up to 10GB. Depending on your app, this might rule out storing files in the db. Having said that, if your app includes 10GB of files, you are probably going to be using a full version of SQL Server or MySQL anyway. You also need extra programming to write the files to the database and to extract them (although there are loads of exampls of how to do this freely available on the world wide web).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 7, 2014 4:30 PM
  • User-1416423428 posted

    I would save uploaded files on a subdirectory, and store their filename/path in the database... instead of cramming their binary information inside the database.  That database will get huge real fast, backups would also be huge and take longer, and you'd probably need a bigger web host package if you have such a big sql database space need (i.e. more expensive for you). 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 8, 2014 2:38 AM
  • User-1716253493 posted
    You can start from saving file to a folder first, store the path to database. Next time you can learn to store file byte to database.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 8, 2014 3:00 AM
  • User-821857111 posted

    That database will get huge real fast

    I have an eight year old database with over 12,000 news items/feature articles in it and associated PDFs, image files etc. It has only just reached the 4GB limit imposed by SQL Express 2005.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 8, 2014 3:45 AM
  • User-1416423428 posted

    I have an eight year old database with over 12,000 news items/feature articles in it and associated PDFs, image files etc. It has only just reached the 4GB limit imposed by SQL Express 2005.

    I guess depends on the website, purpose, activity, needs. 

    A client site's 13+ year old news site, has 43,000 records in database... the SQL database is only 850 MB.  

    But their images directory takes about 26 GB. (High Res photos for other news agencies to download) 
    About 600+ MB in media related files. 
    Another 460MB files in another image directory. 
    Another 5GB in their cartoon daily directory. 

    Storing their images in the same database wouldn't have worked for me. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 8, 2014 4:05 AM

All replies

  • User379720387 posted

    One of the points I recall from previous discussion is that you may not have access to the file system once your application is deployed.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 7, 2014 10:28 AM
  • User-1716253493 posted
    Simple way is storing file in the web then store filename or path to database. You can create link directly to the file when you want to download. If you store it in database, you need to extract the file using handler.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 7, 2014 10:36 AM
  • User-821857111 posted

    The main justification for storing files in the database is security. Only people with access to the database can do anything with the files. So you are less likely to have e.g. images "disappear" (get deleted / renamed) by someone with acess to the file system on the server eg via FTP. You can also control access to static files via a handler which can check if a user is authenticated/in the correct role before serving the file. Backups are simpler too. You don;t have to worry about implementing a separate backup regime for your files.

    The downsides to database storage include database backups being larger and taking longer. Some databases are restricted in total size. For example, SQL Compact can only reach 4GB as can Sql Express 2005 databases. More modern SQL Express database can go up to 10GB. Depending on your app, this might rule out storing files in the db. Having said that, if your app includes 10GB of files, you are probably going to be using a full version of SQL Server or MySQL anyway. You also need extra programming to write the files to the database and to extract them (although there are loads of exampls of how to do this freely available on the world wide web).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 7, 2014 4:30 PM
  • User-1416423428 posted

    I would save uploaded files on a subdirectory, and store their filename/path in the database... instead of cramming their binary information inside the database.  That database will get huge real fast, backups would also be huge and take longer, and you'd probably need a bigger web host package if you have such a big sql database space need (i.e. more expensive for you). 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 8, 2014 2:38 AM
  • User-1716253493 posted
    You can start from saving file to a folder first, store the path to database. Next time you can learn to store file byte to database.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 8, 2014 3:00 AM
  • User-821857111 posted

    That database will get huge real fast

    I have an eight year old database with over 12,000 news items/feature articles in it and associated PDFs, image files etc. It has only just reached the 4GB limit imposed by SQL Express 2005.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 8, 2014 3:45 AM
  • User-1416423428 posted

    I have an eight year old database with over 12,000 news items/feature articles in it and associated PDFs, image files etc. It has only just reached the 4GB limit imposed by SQL Express 2005.

    I guess depends on the website, purpose, activity, needs. 

    A client site's 13+ year old news site, has 43,000 records in database... the SQL database is only 850 MB.  

    But their images directory takes about 26 GB. (High Res photos for other news agencies to download) 
    About 600+ MB in media related files. 
    Another 460MB files in another image directory. 
    Another 5GB in their cartoon daily directory. 

    Storing their images in the same database wouldn't have worked for me. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, June 8, 2014 4:05 AM