1

Is it possible to store pictures,sounds,videos in SQL Database (or any other database) ? If yes what format should it be and please specifiy about the special settings that has to be configured if any. Thanks in advance.

trilawney
  • 1,786
  • 6
  • 28
  • 36
  • 4
    Yes it's possible, you should SEARCH google about blobs... – Federico Vera Apr 09 '12 at 13:29
  • Storing files in your database is almost always a bad idea. File systems are quite good at storing files (the clue is in the name). Just store the meta data and path for the files in your db. – user1191247 Apr 09 '12 at 13:36
  • 1
    See: http://stackoverflow.com/questions/1212991/do-you-think-its-a-good-idea-to-save-billions-of-images-into-database – Somnath Muluk Apr 09 '12 at 13:38
  • Yes , you can do that, and once we know what you are writing your code in we can point you somewhere. but as others have said, if you can avoid doing it, you should. If you can't there are some ways of addressing some of the issues. – Tony Hopkinson Apr 09 '12 at 13:45

2 Answers2

6

In MySQL you can store any binary content in a table using the BINARY or VARBINARY data type for a column. Quite all database system as such a data type. It can be used to store a full file content such as picture, video, sound,... or just a binary snippet.

Nevertheless, storing binary files in a database is considered as a bad practice, because it quite always brings to disappointments. Indeed, a file stored in database cannot be easily processed for a download, an inclusion in a HTML page, a streaming, ... . And it is quite always complicated to manipulate because of its length. Most often, a file sorted in a database is disadvantageous compared to a file stored in a directory. Its is advised to store the file name in the database base, and save the actual file in a physical directory.

Skrol29
  • 5,402
  • 1
  • 20
  • 25
1

Although its generally not recommended to store images inside the Database, its better to store path of the image. Nevethless the images can be stored in the database by using a longblob datatype. Check out this example from MySql forums.

aliirz
  • 1,008
  • 2
  • 13
  • 25