Forum Moderators: coopster & phranque

Message Too Old, No Replies

SQL DATABASE - How documents are stored

I know its a stupid question

         

justa

5:28 am on Jan 31, 2002 (gmt 0)

10+ Year Member



Slap me in the face and call me an idiot.

This may be a stupid question but I have to ask it.

I'm writing up a document management database and need to include word docs, excell etc. I've got the database set out nicely with one exception, I've failed to learn how documents are kept on databases.

I'm guessing there are two possibilities.
1st - Documents are stored wholely within the database as objects, if so what datatype is the field?

2nd - Links to the documents are stored as "char" or "varchar" and you point to a folder called etc/risk_management/docs/

Please alleviate my ignorance.

Josk

10:10 am on Jan 31, 2002 (gmt 0)

10+ Year Member



Oracle allows a blob object of 2gb in size, and your vendow may have something typical. For database that don't allow raw data storage, I tend to just store the path to the file

circuitjump

4:37 pm on Jan 31, 2002 (gmt 0)

10+ Year Member



Thats how I've done it in the past with mySQL I just store the directory of where the file will be at.
/directory/path/word.doc

justa

6:51 am on May 30, 2002 (gmt 0)

10+ Year Member



While I was revisiting some previous threads I came across this which prompted a new question.

I store the directory location of the file in the database. All documents that are uploaded are placed in the htdocs/site/documents folder.

If I delete an entry in the database the record is erased along with the path to the document, but the document remains in the htdocs/site/documents folder.

How would I delete both the record and the document?

Josk

10:23 am on May 30, 2002 (gmt 0)

10+ Year Member



Under Perl...?

unlink($path)

lorax

4:55 pm on May 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



How would I delete both the record and the document?

I use PHP to do both. First I create/edit/delete (depending on what is needed) the document and then I update the record in the db to reflect the change. That way if the create/edit/delete wasn't succesful for some reason, my DB doesn't need to be updated and I can send myself an error msg telling me what failed and why.

ergophobe

5:19 pm on May 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thoughts on the merits of the two approaches...

If you are going to store files as blob objects, any changes you make to the doc will have to be uploaded via an admin tool that you create (basically just a password-protected form that enables file upload and puts the correct paths in the DB). The advantageis that you always go to the same place (same admin page) for all tasks.

If you store the docs as files, you only have to use the admin tool to create a new entry. The advantage is that to update the document (as long as it retains the same name), you will only need Word and an FTP client.

I don't know as I would say that either is easier (using PHP and MySQL), but you or the people you're doing this for may prefer one alternative or the other.

Tom

lorax

5:23 pm on May 30, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you store the docs as files, you only have to use the admin tool to create a new entry. The advantage is that to update the document (as long as it retains the same name), you will only need Word and an FTP client.

You could also add an FTP uploader to the admin and forego having to use an external FTP client. This way the PHP Script would upload the doc and add the information to the db.