title: How to store document in directory instead of database
body: <p>I have a MySQL database that works with electrical measures. It also has a table <code>contracts</code> containing contracts' parameters, and a table <code>documents</code> that contains the blobs of documents corresponding to certain contract:</p>
  
  <pre><code>+-------------+---------------------+------+-----+---------+----------------+
  | Field       | Type                | Null | Key | Default | Extra          |
  +-------------+---------------------+------+-----+---------+----------------+
  | id          | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
  | contract_id | bigint(20) unsigned | YES  |     | NULL    |                |
  | name        | varchar(512)        | YES  |     | NULL    |                |
  | document    | longblob            | YES  |     | NULL    |                |
  +-------------+---------------------+------+-----+---------+----------------+
  </code></pre>
  
  <p>Documents are added and retrieved by users from the program that connects to the database. 
  Recently the database has become too big, and I want to reduce its size at the expence of documents. So I guess that a field <code>document</code> should be a text reference to the file. Where should this reference refer to? Should it be a shared folder? How could user`s program access this place? I ask because I want to know what's the best practice in this case. Thanks. </p>