Tuesday, November 15, 2005

Associations

Definition

As discussed before, a traditional filesystem has Files and Directories whereas SpoonFS will have Items and Relationships. This post describes Associations and their usage in the filesystem. Formally, an Association is just a unordered set of Items. In this respect, an Association is similar to a Directory in a traditional file system.

Simple Example

However, the power of Associations extends much further than Directory capabilities. First of all, it is possible for Items (for now, just think of Items and Files as being the same) to be in more than one Association. For example, imagine that Alice has recently taken several photos from her vacation in France. One thing that she could do is create a new Association named Vacation and put all of the recent photos in this Association. Furthermore, assume that Alice visited France because of a fascination with the Eiffel Tower. Alice has several photos from other people of the Eiffel Tower and these are all under an "Eiffel Tower" Association. Now that Alice has taken her own photos, she can also put these under the "Eiffel Tower" Association. Note that this would have been very difficult to do in a hierarchical file system; a picture of Alice in front of the Eiffel tower would need to be in both an "Eiffel Tower" directory and a "Vacation" directory. A hacky solution is available on platforms supporting hard links, but many mainstream filesystems (NTFS and FAT32) do not support this feature.

Associations are Items too

As a parenthetical comment, it was mentioned that Items should be thought of as just being Files. We now extend the concept of a SpoonFS Item to include Associations as well. That is, an Item is either a File, a Spoon, or an Association. Since Associations are sets of Items, it is possible to have Associations contain other Associations. Such a use for sub-Associations could be useful in organizing system files. For example, consider a "School" Association consisting of all of the work done for school (e.g., essays, assignments, OS projects, etc.). Now consider that there is an Association named "CS508" which corresponds to any files having to do with CS508 (e.g., PDF documents corresponding to the papers read). "CS508" could be placed as an Item in the "School" Association (along with other Associations pertaining to courses). Using Associations in this way is mirroring the functionality of a hierarchical file system. In fact, with this example, we wanted exactly a subset type of relationship, which is what hierarchical file systems provide. This example is useful to demonstrate that Associations are more powerful than just hierarchies: they can implement hierarchies (i.e., sub-Associations), but can also do much more (e.g., look at the previous example involving vacation photos).

Dynamic Associations

As defined, Associations are sets of Items. The examples provided so far have offered sets that have a static predicate function. That is, the Association is told that it contains "these files", where "these files" are some set selected by the user. However, the predicate function for an Association can also be dynamic, allowing Associations to grow dynamically as new files are added. As a requirement, we allow Associations to query over the Attributes of an Item. For example, consider an Association entitled "Favourite Songs" in which the predicate function is "All MP3s whose "rating" attribute is 5 or more". An example from business could be "All Contacts that I have sent an E-mail to in the past five days". In this respect, Associations act somewhat like stored queries or views in a database. There is already a similar concept built into modern e-mail clients called virtual folders (such clients include Novell Evolution, Mozilla Thunderbird and Microsoft Outlook). Of course, virtual folders are only defined for mail messages in these applications. The great thing about refactoring this type of powerful behaviour into the filesystem is that all SpoonFS aware applications can benefit from it.

No comments: