Received: from mcp.csh.rit.edu (mcp.csh.rit.edu [129.21.60.9]) by hub.org (8.9.3/8.9.3) with ESMTP id PAA85258 for ; Wed, 31 May 2000 15:05:33 -0400 (EDT) (envelope-from jon@mail.csh.rit.edu) Received: from fury.csh.rit.edu (fury.csh.rit.edu [129.21.60.5]) by mcp.csh.rit.edu (Postfix) with ESMTP id D59C02BF for ; Wed, 31 May 2000 15:05:24 -0400 (EDT) Received: (from jon@localhost) by fury.csh.rit.edu (8.9.3+Sun/8.9.1) id PAA25545 for pgsql-sql@postgresql.org; Wed, 31 May 2000 15:05:15 -0400 (EDT) Date: Wed, 31 May 2000 15:05:15 -0400 From: Jon Parise To: pgsql-sql@postgresql.org Subject: Inheritance heirarchy Message-ID: <20000531150514.A25330@csh.rit.edu> Mail-Followup-To: pgsql-sql@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.1.14i X-Operating-System: SunOS 5.7 (sun4u) X-Archive-Number: 200005/226 I'm not entirely sure what the correct term for this would be, but I'll just call it an inhertiance heirarchy for lack of a more correct name. Anyway, I'd like some pointers on modeling a heirarchical structure where a given "parent" row can have multiple "children" rows, and each "child" has either zero or one "parent"'s. Each "child" can also be a "parent" to many more "children". I'll need to traverse the hierarchy from a given parent down through its children and from a child throw all of its parents. I'm looking to distribute a quantity of "points" from the children back up to the parent(s) in accordance with a predefined referral scheme. The distribution will be based on predefined percentages (as in, a parent receives 5% of the children's share). I think the closest existing structure that I'm familiar with that follows these rules would be a so-called "pyramid scam", but that has a nasty, dubious connotation, and it's not why I'm trying to do. Anyway, any pointers or examples would be deeply appreciate. I'm not an SQL or data modeling newbie, but I'm sure you'll agree this is a tad on the more advanced side. Oh, and Joe Celko's book "SQL for Smarties" is already on order. =) -- Jon Parise (jon@csh.rit.edu) . Rochester Inst. of Technology http://www.csh.rit.edu/~jon/ : Computer Science House Member