3

This question has already been asked in this forum, but I really cannot understand those answers since I am still not an expert and has not dealt with this kind of scenario earlier. I am still a student.

I am going to build a loan management system and in my system there is a form in which user can attach scanned documents. These are not large documents and they are all image types. I need to store those electronic documents in my database (in a specific table) which will be used by the officers for future references. How do I store those files in the DB? Is that the document path (directory) that we are recording in a table?

I am really grateful for anyone who could show me how to accomplish this task? If you can give me an example that would be really helpful!

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Gihanmu
  • 407
  • 2
  • 8
  • 15
  • I would suggest storing the scanned documents to a directory and storing their path in the database. Full disclosure, I've never worked with a system to store images in a database but have read it negatively affects performance. – user2027202827 Mar 15 '14 at 05:44
  • @hobenkr - Thanks. But I still did not get it properly – Gihanmu Mar 15 '14 at 05:47
  • You could use a Blob data type, but I agree with @hobenkr you should re-think your approach. check the Docs http://dev.mysql.com/doc/refman/5.0/en/blob.html if you're interested though – Bryan Mar 15 '14 at 05:48
  • @Bryan - Do you have any alternative suggestion? – Gihanmu Mar 15 '14 at 05:53
  • 2
    store the directory you save a file in a varchar field and reference that field to get the location of the document – Bryan Mar 15 '14 at 05:55
  • @Bryan - It gave me some idea, I will study on it further. – Gihanmu Mar 15 '14 at 05:59

1 Answers1

0

Before you store the document in a file and a filename in the database, ask: what will protect the file?

If the document is in the database, the DBMS ensures that as long as record of the document exists, so too does the document itself. If the document is updated, the DBMS ensures that either both versions are kept, or one replaces the other, and keeps the associated attributes in sync.

The moment you move the document outside the database, all those affordances are gone. Do you want to surrender that, in exchange for some dubious convenience or efficiency?

Keep your data in your database. Just because some data are "a document" stored in "a file" doesn't change much, if you care about them.

James K. Lowden
  • 7,574
  • 1
  • 16
  • 31