Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I save .pdf documents to the database or a folder that need to be searched

I have a bunch of PDF documents that I need to use in a website I am making. I do need to be able to search the PDFs as well. So is it better to save these files to the database or to a file folder? Also, in both cases how do I search them? I will basically be searching them for 1 or 2 words and return the list of PDFs that have the results in them. What is the best and easiest way to do all of this? Also, the PDF file will be changed once a year at the most often and sometimes even less often and I will not need to keep revision history.

like image 419
Ben Hoffman Avatar asked Mar 01 '10 16:03

Ben Hoffman


2 Answers

You can store the PDF inside of a table using a varbinary field and an extension field. Then you can take advantage of the Fulltext serch engine to search inside of the PDFs. You will have to install a PDF iFilter in your SQL server. I do not know if this is the easiest way to do it, but I know it works great. I am using that schema to store hundred of thousands of documents and it performs great.

like image 119
Jose Chama Avatar answered Sep 28 '22 09:09

Jose Chama


This is the same argument over and over again about saving things in the file system vs saving them in the database. Sadly, there is no right or wrong answer, and it all depends on the scope of your project. Take a look at this stackoverflow question. It's about saving images in a DB, but it's the same principle.

Store pictures as files or in the database for a web app?

like image 31
Aaron Avatar answered Sep 28 '22 08:09

Aaron