What are the advantages and disadvantages of storing binary data in a SQL table vs a network drive? Possible Duplicate:
  Files - in the database or not?  




I've been reading "Programming Entity Framework Code First" (http://www.amazon.com/Programming-Entity-Framework-Code-First/dp/1449312942).

There are a number of examples given where information about a particular person is stored in a SQL table, including the person's photograph (a digital image stored in a VARBINARY field).

In all of the systems that I have worked on, any kind of file associated with a record in SQL is stored on an ordinary network drive; not in SQL.  I would imagine that there must be some reasons for this, so here's my question:

What are the advantages and disadvantages of storing binary data in a SQL table vs storing the same binary data on a network drive given that the binary data is associated with a record in SQL?
One advantage is that if the program that needs to access the data does not have access to the file system, it's not a problem! If the database is accessed by multiple applications on different systems, they probably shouldn't have file-system access to your database server. You could always store a path and they create a web service to allow these applications to request a file on a specific path, but that's a bit more work so you'd better be sure it's worth it. Keeping the binary data in the database and returning it in the record set is simpler.

A disadvantage is that your database will now require more storage space and this will impact backups and other things. Sometimes having large amounts of binary data in a database can also have an impact on performance. Some DBAs handle this by moving BLOB data to tables in separate schemas that are managed differently from the main "data" schemas. While such techniques may work, you might need a deeper understanding of database management and tuning to get it working well, if you have LOTS of binary data.