Store Files in SQL Server or keep them on the File Server?

末鹿安然 提交于 2019-11-30 05:33:35

I would have both.

I would keep the files renamed with an unique name, thus easier to manage, and i would keep all meta data inside the database (file name, content-type, location on file system, size, description, etcetera), so the files are accessed through the database (indirectly).

Advantages:

  • files are easy to handle; you can bring several drives in the mix
  • the database can keep any number of meta information, including file description on which you can search against.
  • keep track on file accesses and other statistic information
  • rearrange the files using various paradigms: tree (directory structure), tags, search or context

You can have compression on a drive also. You can have RAID for backup and speed.

rule of thumb for doc size is:

size < 256 kb: store in db
265 kb < size < 1 MB: test for your load
size > 1 Mb: store on file system

EDIT: this rule of thumb also applies for FILESTREAM storage in SQL Server 2008

If you upgrade all the way, to SQL Server 2008, then you can use the new FILESTREAM feature, that allows the document to appear as a column in a table, yet to reside as a file on a share, where it can be directly accessed by a program (like Word).

What kind of documents are we talking about?

Storing documents in your SQL server might be useful because you can relate the documents to other tables and use techniques like Full-text indexing and do things like fuzzy searches.

A downside is that it might be a bit harder to create a backup of the documents. And compression is also possible with NTFS compression or other techniques.

Are these documents text based and are you planning on using SQL Server's full text search to search these documents? If not, I don't see any benefit in storing these documents on the database. Ofcourse, you can always store the meta data related to the documents including the path information to the database.

A big benefit of stroing docs in the DB is it becomes much easier to control security access to them, as you can do it all via access control in your app. Storing them on a file server requires dealing with access priveledges at the file and folder level to prevent any direct access. Also have them in a DB makes for a single point of backup, so you can more easily make a full copy and/or move it around if needed.

Rather than writing a custom DMS (document management system), you should probably consider buying one or using WSS / SharePoint as this will handle all the mundane details (storage, indexing, meta-data) and let you build your custom functionality on top.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!