I'm building an ASP .NET web solution that will include a lot of pictures and hopefully a fair amount of traffic. I do really want to achieve performance.
Should I save the pictures in the Database or on the File system? And regardless the answer I'm more interested in why choosing a specific way.
SQL Server allows storing files. In this article, we learned how to insert a single image file into a SQL Server table using T-SQL.
I'd say store all images in an images folder, then store the path of the images in the database, for example if we are doing posts and each post has an image, we could upload the image into /webroot/images/ and save the path /webroot/images/someimage. jpg in the database.
Generally databases are best for data and the file system is best for files. It depends what you're planning to do with the image though. If you're storing images for a web page then it's best to store them as a file on the server. The web server will very quickly find an image file and send it to a visitor.
To insert images into a database, the database must support images. Images are stored in binary in a table cell. The data type for the cell is a binary large object (BLOB), which is a new SQL type in SQL3 for storing binary data.
Store the pictures on the file system and picture locations in the database.
Why? Because...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With