0

I know that blob is a data type for binary data as integer is a datatype for int. As they say, It's used to store files directly in database (we move our audio file into blob, and save that blob in database).

Question 1) why to store blob for audio if I can just put the audio in storage for example path /var/www/audio.mp3 and in database I store path_name /var/www/audio.mp3?

Question 2) which is better ? how netflix stores movies? just blobs or what?

Question 3) Curious if there're any cons or prons if you could just give me ideas so that I know when to use them .

Chemistry
  • 165
  • 7
  • 2
    Imho this question is too broad and the answer will partially be opinion-based and therefor off-topic. And this topic belongs on https://dba.stackexchange.com -> [blob - Files - in the database or not? - Database Administrators Stack Exchange](https://dba.stackexchange.com/questions/2445/files-in-the-database-or-not) – Andreas Sep 06 '18 at 15:12
  • Maybe you'll find this useful: [Storing Images in DB - Yea or Nay?](https://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay) – enxaneta Sep 06 '18 at 15:23

3 Answers3

1

Putting the blob in the database, rather than a file, allows you to grow to multiple servers with load balancing. If you put the data in files, you would have to replicate the files between the server. Most databases have built-in replication features, this isn't as easy for regular files.

Barmar
  • 741,623
  • 53
  • 500
  • 612
1

Better to use external storage/cdn for serving such kind of large content.

How Netflix and our works? They upload content on external bucket i. e. S3 and write file name in db for identification. According to user file access frequency that file cache on CDN/edge location. User will get awesome experience while content server from their nearest edge location

Mohit M
  • 769
  • 7
  • 15
0

With blob you can store all kinds of stuff. Do you communicate with an API via SOAP or JSON and want to store it in the database? Use a blob. Want to log what a user filled into a form when it threw an exception? Store the entire post as a blob. You can save everything as is. It's handy for logging if you have different data formats. I know an API which expects some data via SOAP and some as JSON. To log the communication I use blob because the response may be in XML, JSON, a number (http code 203 for empty but accepted) or an exception as array.

DataVader
  • 740
  • 1
  • 5
  • 19
  • Agree, but a main question gets arised when it's about just images or movies. but i think no one in the world stores movies in blobs in database . I know it would be super safe , data integrity and so on, but There's no way to store long movies maybe. what do you think? Am I right? but if I ever need to store images, I'd go to store it as blobs as I won't have headaches deleting or inserting files in filesystem. right? – Chemistry Sep 06 '18 at 15:34
  • Movies are not stored in databases because you would run out of disc space pretty fast, so that is not advised. Everything smaller (lice icons, mail attachments,...) would be legit and I store those things as blobs. Only store paths for big files like movies. Saving small files as blobs saves you trouble when migrating the system, helps your performance and even results in less code. You don't need to connect to an additional FTP-server to fetch the files for example. Imagine looping through a few rows and downloading the files separately when you can do a simple select. – DataVader Sep 06 '18 at 15:46