1,105,406 Community Members

Database filemanagement

Member Avatar
gunnarflax
Junior Poster
164 posts since Jan 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 10 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi!
Basically, what I'm trying to do is a site for online storage of my own files, like Microsofts SkyDrive service. One thing I'm wondering about is what way that would be most effective to organize the files? My first thought was that when I upload the files to the server I also register the files in a database where I save all the information needed (location, file name, url etc.). With that information I can easily make all the necessary links and such that I need to obtain the files. I figured this must be faster than check the contents of every folder and then print out the file information from there. But if I skip the database it will be much easier handling the files and there will be no need to change the stored information when I move files around.

So what puts less weight on the server? Should I go through the hassle with the database, and if I do, do I gain any server efficiency from that?

Thanks!

Member Avatar
vaultdweller123
Posting Pro
577 posts since Sep 2009
Reputation Points: 32 [?]
Q&As Helped to Solve: 84 [?]
Skill Endorsements: 2 [?]
 
0
 

i recommend you use database to store information of your files... it's a more professional approach.

Member Avatar
gunnarflax
Junior Poster
164 posts since Jan 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 10 [?]
Skill Endorsements: 0 [?]
 
0
 

i recommend you use database to store information of your files... it's a more professional approach.

But isn't it just as effective to just get all the information from reading the directory and the file information?

Member Avatar
parkeyparker
Newbie Poster
16 posts since Apr 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

One benefit to using a database is that you would be able to set permissions and things such as shared files etc and hidden files. But you would also be able to have more detailed information about the files such as descriptions for each of them. If those options are not necessary to you then you should probably just use the information from the file system as it is easier. However I am not sure that it is any less strain on the server as if it is a hosting provider then many hosts have dedicated database servers and so it would be work spread over many processors instead of just a lot of strain on the one webserver process.

Im not an expert and these are just opinions so use them however you wish but let us know what you decide to do.

ParkeyParker

Member Avatar
diafol
Where are my eyes?
12,986 posts since Oct 2006
Reputation Points: 1,821 [?]
Q&As Helped to Solve: 1,849 [?]
Skill Endorsements: 92 [?]
Moderator
Featured
Sponsor
 
0
 

With DB, you can give files faux names and locations. You could just name files: fileX.ext where the 'ext' is the true extension of the file and X can relate to the file's id within the db. This means that you can save all files within the same folder without any danger of overwriting etc.

So:
files table
id (Primary Key etc)
filename (actual physical name on server)
author (Foreign Key??)
ext (e.g. jpg, gif, pdf etc)
faux_file (false name or alias)
faux_folder (false path)
status (hidden, protected etc)
size
title
description
date_created
date_last_modified
(etc)

when file uploaded:
enter all file details to DB except physical filename
get ID via mysql_insert_id()
enter DB physical filename and rename physical file to fileX.ext
[X = id, ext = from db]

This is off top of my head, bet it could be made smoother with a bit of thinking.

You can search effectively as opposed to iterating over disparate folders - yuk. It also offers functionality w.r.t protecting document location.

Member Avatar
gunnarflax
Junior Poster
164 posts since Jan 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 10 [?]
Skill Endorsements: 0 [?]
 
0
 

One benefit to using a database is that you would be able to set permissions and things such as shared files etc and hidden files. But you would also be able to have more detailed information about the files such as descriptions for each of them. If those options are not necessary to you then you should probably just use the information from the file system as it is easier. However I am not sure that it is any less strain on the server as if it is a hosting provider then many hosts have dedicated database servers and so it would be work spread over many processors instead of just a lot of strain on the one webserver process.

Im not an expert and these are just opinions so use them however you wish but let us know what you decide to do.

ParkeyParker

That's true, I think I will be working with a database then. After all, you can save much more information then :) Thanks for the replies!

Member Avatar
vaultdweller123
Posting Pro
577 posts since Sep 2009
Reputation Points: 32 [?]
Q&As Helped to Solve: 84 [?]
Skill Endorsements: 2 [?]
 
0
 

then mark this thread solved then.... marking thread solved is a way of saying thank you.

Question Answered as of 4 Years Ago by vaultdweller123, diafol and parkeyparker
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: