angfreak
angfreak

Reputation: 1003

Add file into a SQL Server table

I have an online user admission portal, in which I have 4 resume columns - for father, mother, guardian and applicant. User uploads these resumes when he applies for a particular course. Which method should I use to store these uploaded resumes (files in .docx format) to my database?

  1. I have an uploader and I create a folder then save .docx file into this folder and store the file path in a filepath table column;

    or

  2. I have a column of type varbinary(MAX) and store .docx file itself in this column.

Which method is more secure and has better performance?

Upvotes: 0

Views: 1560

Answers (2)

Ilkka
Ilkka

Reputation: 306

I prefer option #2, because then your resumes are contained within the database and you don't have to worry about backing up external files outside the database. I think this option is also more secure, because you don't have to worry about NTFS permissions either. Many times SQL Server is placed behind a firewall that's between app/web and sql server. In that sense, your data is more secure. It depends on the architecture of your infrastructure.

Remember that databases can grow very large and you will have to pay attention to your query performance. When done right, no problems at all.

Upvotes: 0

Adriaan Stander
Adriaan Stander

Reputation: 166396

Instead of storing the files in a column in the database, I would have a look at using FILESTREAM (SQL Server)

FILESTREAM enables SQL Server-based applications to store unstructured data, such as documents and images, on the file system. Applications can leverage the rich streaming APIs and performance of the file system and at the same time maintain transactional consistency between the unstructured data and corresponding structured data.

Upvotes: 3

Related Questions