Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Storing Documents and Images - In the database or as a link?

2 views
Skip to first unread message

Dave Smithz

unread,
Oct 25, 2004, 3:49:31 PM10/25/04
to
Hi There,

Being quite new to MS-SQL I would like to ask if there is a general opinion
of what approach should be taken to storing things like external documents
and images in databases.

Should the actual files be stored within the database, or instead should
links to the files on a file server or something similar be stored instead.

For the end user I imagine it is easier to have everything stored within the
database, because doing it the other way in effect gives another level of
management because there is the need to perhaps manually look after the file
server with all the image files or document files on.

In my particular case, I am building a database where the users use a great
many Word documents. For example, I particular record might have a number of
different Word documents associated with it.

I was going to create a "Documents" table that all documents were stored in
(including meta data about each document because it will be really useful to
be able to search for documents so that they can be reused).

In this table I was in a dilemma as to whether to actually store the
documents in the table. Other then the performance hit and memory
requirements this will require, are there any other disadvantages?

What are the general thoughts when a database needs to manage a lot of pdf
and word documents?

Thanks in advance.

Dave.


nib

unread,
Oct 25, 2004, 4:08:18 PM10/25/04
to
inline...

Dave Smithz wrote:
> Hi There,
>
> Being quite new to MS-SQL I would like to ask if there is a general opinion
> of what approach should be taken to storing things like external documents
> and images in databases.

Depends on what your situation warrants.

>
> Should the actual files be stored within the database, or instead should
> links to the files on a file server or something similar be stored instead.

Either works. Both have pros and cons.

>
> For the end user I imagine it is easier to have everything stored within the
> database, because doing it the other way in effect gives another level of
> management because there is the need to perhaps manually look after the file
> server with all the image files or document files on.

You can automate the storage/retrieval of the documents even if they're
stored in a directory instead of the database.

>
> In my particular case, I am building a database where the users use a great
> many Word documents. For example, I particular record might have a number of
> different Word documents associated with it.
>
> I was going to create a "Documents" table that all documents were stored in
> (including meta data about each document because it will be really useful to
> be able to search for documents so that they can be reused).
>
> In this table I was in a dilemma as to whether to actually store the
> documents in the table. Other then the performance hit and memory
> requirements this will require, are there any other disadvantages?

Personally, I lean towards using the database for storage. A quick list
of why:

1) Store multiple documents for the same entity without having to create
naming standards
2) Security
3) only allows editing via your applications

cons:

1) requires additional programming on your end due to dealing with blobs
2) takes more db space (but, you'll be taking up the space anyway)

Zach

Erland Sommarskog

unread,
Oct 25, 2004, 6:10:42 PM10/25/04
to
Dave Smithz (SPAM FREE WORLD) writes:
> Being quite new to MS-SQL I would like to ask if there is a general
> opinion of what approach should be taken to storing things like external
> documents and images in databases.
>
> Should the actual files be stored within the database, or instead should
> links to the files on a file server or something similar be stored
> instead.

Many people advocate storing files on disk and only store the links in
the database. Undoubtedly, this solution is a lot simpler to implement,
since to store the documents in the database you need to use the image
datatype which is not very simple to work with.

But if you store files on disk, you don't have the consistency check that
transactions buys you. You may store a link in the database, but the
file is for some reason not stored on disk or vice versa. And if someone
uses the Explorer to search the directory, he might delete files by
accident or malice. Of course a malign intruder may delete data in your
database, but you are probably safer to accidents.

--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

Ellen K.

unread,
Nov 6, 2004, 11:21:26 PM11/6/04
to
If you store them in the database you know for sure where each one is.
If you store the path, people can move the files and then your
database is kinda useless.

On Mon, 25 Oct 2004 20:49:31 +0100, "Dave Smithz" <SPAM FREE WORLD>
wrote:

0 new messages