Hi Janet

Ok, you just pwnt my knowledge on folder / file storage :-) Adjacency wha? Kind of reminds me of the phone interview I had when someone asked for a definition of referential integrity... 3rd year Uni database theory learnt over a decade prior to the phone conversation was difficult to recall at that instant.... but I digress.

I have to store folders and files in a database design for an application I am developing. I created an initial folder table similar to yours. The "right way." Then worked out what I wanted to be able to do with the data stored in that table, from within the application. omg. I have to what? NB: this was not using SQL Server. I'm only hinting that when I was starting out with this problem, the solution looked like far too much work :-)

Being the decidedly lazy developer that I am, I totally denormalised (to the nth degree) the design, giving me:

Folder:
-------
FolderID
FolderPath

File:
-----
FileID
FolderID
FileName

My design is not used directly for display purposes, I do not have to build a tree with it, but I imagine it would not be that difficult if I had to. I probably will in time. MS Windows can be funny: when drawing a tree, it displays a [+] next to a directory whether that directory contains something or not. It's not until you click / dbl-click it that the display updates - removing the [+] if there are no subdirectories in there. I figure if Windows can do it, so can I. A LIKE and a '%' would probably suffice.

The most common actions I have to perform (to date) are:
does this file <some path \ some file> exist in the database?
list all the files in <some path> folder?

I have also totally ignored the possibility (for now) of a tree change (pun intended) but figure a well placed '%' in an UPDATE LIKE statement should work.

The fact that others have developed solutions to the problem does not surprise me, and using someone else's working code is always a great option. My "solution" feels amateurish by comparison, but it's satisfying my Rule 1 (does it work?), and is darn simple to implement. Hope it provides food for thought.

It would be interesting to put together a quick list of functions:
add file (to folder)
rename file (within folder)
delete file
move file
add folder
rename folder
move folder
delete folder
draw tree
list files in folder
does file exist in folder

and see the code / SQL associated with each one from the adjacency model or any other wacky models people may come up with.

HTH
Aaron


J MacKay wrote:
Aaron

http://support.microsoft.com/kb/248915

It sounds like you're hinting that the adjacency model is not the way to go? I should have specified that I'm not building this from scratch. I'm working with pre-existing structures and code (pre-MX and cfcs). So any changes must coexist with the existing structure (adjacency model) for now.

I'm not arguing the merits of one method over the other. I agree there are different advantages to each approach. I think the original designers went with the adjacency model because they expected a lot of structural changes which can be a more expensive operation when using nested sets. But as you hinted, querying a hierarchy is usually easier with nested sets :)

Truthfully I'm not always a fan of the adjacency model. But thats what I've got to work with right now. If you have any thoughts about converting it to something more managable or performant without drastically disturbing the existing structure I'm "all ears".
Janet


--

------------------------------------------------------------------------
Don't be flakey. Get Yahoo! Mail for Mobile <http://us.rd.yahoo.com/evt=43909/*http://mobile.yahoo.com/mail> and always stay connected <http://us.rd.yahoo.com/evt=43909/*http://mobile.yahoo.com/mail> to friends. You are subscribed to cfcdev. To unsubscribe, please follow the instructions at http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]


You are subscribed to cfcdev. To unsubscribe, please follow the instructions at 
http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL 
PROTECTED]

Reply via email to