SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Nov 2006
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Files and Folders

    If one were to store all their data in one "folder" say 99 files and then use a database to organize these files into what the end user sees as Files and Folders, how would that look implemented in a database

    Let me ask it in another way just to make sure I'm understood... Say Windows... All the files are stored onto the harddrive in no particular order. How does an operating system use a database to tell the computer that this file is in such and such folder

    Geez I feel like I'm talking Gibberish

    Simplifying it once again
    Have a bunch of files in one folder
    All the files are linked into the database say
    Id | File location
    Now one wants to display to the end user a structure of folders (a form of organization) without moving the file's location.
    There... That is clear...

    I think it will be interesting hearing about the different techniques that can be used
    Please...Never describe anything to me using foo and bar.

  2. #2
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A bit confusing yes but I think I understand. I did something similar a while ago...basically all I did was add a parent attribute that referenced an item's ID. The script would display all top level items and keep searching for their 'children' until null was returned.

    So you have all the files in folder X on the hard drive, how are you determining what "fake" folders to display through the database? And what file goes under what folder?
    Nick . all that we see or seem, is but a dream within a dream
    Show someone you care, send them a virtual flower.
    Good deals on men's watches

  3. #3
    SitePoint Addict
    Join Date
    Nov 2006
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well the thing is, i would make the user establish whatever folders they need but I will use the following example/

    alright 99 files
    lets say that
    32 of those files are Text files
    12 are pictures that are .tiffs
    20 are pictures that are .jpegs
    15 are pdfs
    20 are mpgs

    Alright now lets say this user decides he wants this type of folder structure
    [Folder]/[SubFolder]/[Subfolder]/(Number of documents in folder excluding folder)
    Folder/My Documents/(3)
    Folder/My Documents/PDF/(15)
    Folder/My Documents/Textfiles/(15)
    Folder/My Documents/Textfiles/Programming log/(5)
    Folder/My Documents/Textfiles/May 7th/(3)
    Folder/My Documents/Textfiles/Journal/(2)
    Folder/My Documents/Textfiles/Commentary/(4)
    Folder/Images/(10)
    Folder/May 8th/(3)
    Folder/April 10th/(3)
    Folder/May2nd/(6)
    Folder/Movies/(20)

    How would you describe the Parent/Child relationship in a table?
    Please...Never describe anything to me using foo and bar.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by prince_mallow View Post
    How would you describe the Parent/Child relationship in a table?
    one way is with the adjacency model

    see Categories and Subcategories

    i'm not saying that's the best way to store folder and file information, but it shows you how a hierarchy can be saved in a single table
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •