Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Is It A Good Practice To Store Image Or Other Binary Files Directly In A Mysql Database
anzoone
post Jan 23 2007, 09:58 PM
Post #1


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 7
Joined: 23-January 07
Member No.: 19,809



Hello to all of you beautifull people out there, I am new to MySQL, i just wanted to know if its a good practice to directly store images and other binary files in a MySQL database. Any one with help? Thanks
Go to the top of the page
 
+Quote Post
TavoxPeru
post Jan 23 2007, 11:21 PM
Post #2


Super Member
Group Icon

Group: [HOSTED]
Posts: 722
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579



QUOTE(anzoone @ Jan 23 2007, 04:58 PM) *

Hello to all of you beautifull people out there, I am new to MySQL, i just wanted to know if its a good practice to directly store images and other binary files in a MySQL database. Any one with help? Thanks

Well, in these days where we can get incredible storage devices -hard disks, dvds, cds, etc.- with huge capacities, i dont know exactly if it is a good practice to do that because i dont have any statistics about it, i think that it is not a problem to store binary data directly in a database.

Personally i don't do that, in all cases that i know that i gonna deal with this situation i always prefer to store in the database only a reference to the image or binary data using a string fields to alocate its file name and folder name.

Best regards,
Go to the top of the page
 
+Quote Post
uapconsole
post Jan 24 2007, 06:10 AM
Post #3


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 24
Joined: 10-February 06
Member No.: 11,194



It is a practice used by many developers I know. It is possible to store a binary image file such as a .jpeg or .gif. However, I recall working on a project where doing this was the "easy way out." However, I recall this solution tends not the be the most efficient way of doing things.

When my colleague and I tried this, we noticed that the SQL databases became very large. Furthermore query processing tend to be slower. Things just felt "sluggish." We did not think anything was wrong, as we've read that it was a legitimate practice to store images directly, in binary, in the SQL database. However, further research revealed that there is a more efficient way.

We dumped all the images in a read-only directory. We simply converted the "IMAGE" column field to "IMAGE_PATH." We simply stored the paths of the images in our "image dump" directory under this field.

So, we simply pointed the SQL database in the right direction, when an image query is made.

The database behaved much better after these modifications. Everything just felt more efficient.

Hope this helps, good luck.
- Demirelli
Go to the top of the page
 
+Quote Post
Quatrux
post Jan 24 2007, 11:36 AM
Post #4


the Q
Group Icon

Group: [HOSTED]
Posts: 999
Joined: 13-July 05
From: Lithuania, Vilnius
Member No.: 7,059



Yeah, in my practice I found that it is much better to store your images as binary files somewhere and not in a database like mysql, because it is much faster for apache as a httpd server to just transfer a binary file to a user with the right headers, same with a html file or any other file which doesn't need parsing, for example php. Using extra resources, like mysql database, which requires different sql querys, imagine you need to show to a user 10 or 20 images at one request.. imagine you have 100 MB of pictures/images..

Besides, it is much easier to organize your pictures when they are stored as binary files in some directories, you just upload them and similar, you can give an id for every image if you want to or if you don't want to show the image directory, you can worj with the image using a language like PHP.. you won't need to waste time to store the images into databases, you won't need to waste time to see what you have in a database if talking about images or other binary media. Imagine you have a database with 20GB of images, you would have a lot of problems, due to making backups or restoring backups would be hard, repairing tables would be hard to or would take time and etc.

The only good way of storing binary data to a mysql database for me is that if you have a very big site or something, which requires a lot of resources and you can spend money for a mysql server just for binary data, when it is a very good way, because all the other servers which are running can get the image by making a mysql query and if you have 20 servers, you don't really need to have the images stored (imagine if images take over 36GB) on every machine, you save space that way, but for simple developers and websites, I don't see anything good about that. wink.gif
Go to the top of the page
 
+Quote Post
yordan
post Feb 15 2008, 07:37 PM
Post #5


Way Out Of Control - You need a life :)
Group Icon

Group: [MODERATOR]
Posts: 1,919
Joined: 16-August 05
Member No.: 7,896



Have a look at the way, here offered by astahost cpanel, the 4image system works.
In the mysql database are stored the data and the indexes describing the images and the path to have the images and which thumbnails are associated with, and where the thumbnails are, and the guest's comments. Each set of database data points to the place where the htmls images are stored, these are subfolderes named 1, 2, 3, etc.. in the "media" folder, so everything is inside the Unix or windows fileystem.
so, the php programs offer the logic, the mysql database offers the data organizing, and the data are in filesystems. This is the ideal combination of the stongpoint of each component.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. MySQL - Trouble With Bulk Insert Statements(3)
  2. Recover Tables From A MySQL .frm File(6)
  3. Mirror My MySQL Database To Another Mysql Server(4)
  4. How To Connect MySQL With Flash?(8)
  5. MySQL, Multiple Tables(24)
  6. Permission Problem With Mysql Database Creation(8)
  7. Mysql And Php(15)
  8. Problems With Php Saving Data Into Mysql(6)
  9. Login System Using A Mysql Db(4)
  10. Oracle Vs. Mysql Vs. Postgresql(9)
  11. Subqueries In Mysql(1)
  12. Apache Php With Mysql On Windows [solved](9)
  13. Not Understanding Mysql(4)
  14. Mysql Script Help(3)
  15. Mysql - So Hard(14)
  1. Mysql Problem(1)
  2. Connecting To A Remote Database(9)
  3. Database(1)
  4. Sun Bought Mysql(6)
  5. Integrate Access Database Onto Intranet Site(5)
  6. Mysql Backup With Another Address?(4)
  7. I Have An Error With My Mysql Connection(7)
  8. Accessing Ms Access Database From A Centralized Location?(4)
  9. Mysql And User File_priv(0)
  10. Mysql Database Management(1)
  11. Mysql Database Entry By Excel Sheets(2)
  12. Mysql On Computer(9)
  13. Space Needed For Database(9)


 



- Lo-Fi Version Time is now: 24th July 2008 - 01:21 PM