SQL filesystem part 1
NTFS, FAT, ext2, hpfs, they are all types of filesystems. They are what makes referencing files possible on a hard disk and it is a quite a sophisticated piece of software. In essence, a filesystem is just a collection of records with a entry point for the operating system to load the file from into a specified program or pre-defined action. So if we consider that a filesystem is a database of files, could a filesystem be created in SQL using various methods of computation?
To begin with, we have to decide what this particluar filesystem has to do. Since we simply assume that this filesystem will handle requests from the operating system to load files with a specific manner, we could concivably build a database where every file is held in a table and every file has a association applied to it. In a modern operating system, the concept of directories is also a consideration. From this, we could assume the following structure of tables:
File(ID, dirID, filename, entrypoint, progID)
Prog(ID, ext, fileID)
Dir(ID, name, parent)
Prog(ID, ext, fileID)
Dir(ID, name, parent)
In the above structure, child and parent are ID numbers of another dir record unless -1, which indicates the root of the drive. Every ID is a numerical number from 0..n, the entrypoint is a hexidecimal representation of entry point for the operating system to read the file from and every other record is a varchar type with a 255 maximum limit. That meant, in this structure, a file could have a n.n name. Also, the system can be designed to work with specific integer data types. From a MySQL inmplementation, you could have the ID be a unsigned int type, so in theory you could have 0 -> 4 294 967 295 files in the same number of directories with the same number of unique identifications. That makes for quite a diverse filesystem structure.
Of course, this is not a true implementation of a real filesystem as it lacks many of the nesserary features to be a real file system. The use of a SQL filesystem is therefore, limited but could still be used in a system for another purpose such as experimenting with search algorithims (more on that soon).
In the next article, the SQL filesystem will be realised through the representation of a Entity Realationship Diagram and also through proper SQL statements.
19-05-2008: Child property from Dir table removed to allow for 1:* relationship to exist properly.
Comments
