EnzymeTemplates slash-style comments demo. "The self is that relation which relates itself to itself" -- Kierkegaard One of the new features of EnzymeTemplates is the ability to specify a new kind of relation, called a reflexive relation. This is for database tables that relate themselves to themselves. This usually results in a tree structure. Perhaps an example will demonstrate. Slash (http://slashcode.com or http://phpslash.org) uses a comments table that looks like this (simplified): TABLE comments ( cid int, pid int, subject varchar, ... etc. ... ); Now, every comment has a cid. The pid can be null. The pid is the cid of the "parent" comment for every comment. Thus, pid is actually a lookup into the comments table. Thus, each comment has one parent and potentiall many children. Assume we have a comment with cid Xc and pid Xp. To determine its parent comment, simply SELECT * FROM comments WHERE comments.cid = Xp; To determine its children comments, simply SELECT * FROM comments WHERE comments.pid = Xc; This is what the Reflexive Relation does for you, automatically. You just specify what field the table should "reflex" on, and you get a tree structure automatically. See comment_objects.inc for the details of how to specify this. Thus, every comment object has two special objects, one called "Parent" and the other called "Comments" - the former is a single object of type Comment, and the latter is an array of Comment objects. Simple, right? You bet. To install the sample data, just create a table called "comment" and do: % mysql -p comment < comment_data.sql This will create a database with a few bogus comments. You can view these comments, and add your own by pointing your web browser at the demo5.php3 file.