flak@slovax.UUCP (Dan Flak) (01/12/88)
Here's a brain teaser for you folks using Informix 3.30. (I can't
validate SQL since I don't have it).
The schema looks like:
database foo
file family
field name type character 20 index primary
field parent type character 20 index dups.
end
The data entry is set up (using PERFORM) so that once the first record
is seeded into the database ("ADAM" or "EVE" if you prefer), all other
records validate from the "name" field to accept legal values for the
required "parent" field. Notice that the "index primary" in each field
forces each individual name to be unique.
The challenge:
Write a progam using ACE and/or C which will accept as its
first argument the name of any ancestor, and produce a list of all
descendants for as many generations as are loaded in the database.
I've run across this problem working with "Task Organizations" with
the U.S. Army, but I could also see an application in genetics,
railroad management (i.e. trains, and trains of trains), or any other
problem where the whole is equal to the sum of its parts, but those
parts aren't always permanently assigned.
I really would like to see how others have solved this problem.
--
{hplsla,uw-beaver}!tikal!slovax!flak
Dan Flak-R & D Associates,3625 Perkins Lane SW,Tacoma,Wa 98499,206-581-1322jfh@killer.UUCP (John Haugh) (01/14/88)
In article <2678@slovax.UUCP>, flak@slovax.UUCP (Dan Flak) writes: > Here's a brain teaser for you folks using Informix 3.30. (I can't > validate SQL since I don't have it). > > The schema looks like: > > database foo > > file family > > field name type character 20 index primary > field parent type character 20 index dups. > > end [ stuff deleted ] > The challenge: > > Write a progam using ACE and/or C which will accept as its > first argument the name of any ancestor, and produce a list of all > descendants for as many generations as are loaded in the database. > -- > Dan Flak-R & D Associates,3625 Perkins Lane SW,Tacoma,Wa 98499,206-581-1322 This is basically impossible in ACE. You can get N generations using N read statements. Watch - database people end define param[1] person type character length 20 end read into children parent, child = name where parent = person end { now I have the first generation } read into grandchildren children, grandchild = name joining children.child = optional parent { now I have the second } sort by parent, child, grandchild end format every record end To get the third generation you need a third read. It would look similiar to the second, except, the new field would be aliased to `greatgrandchild'. Just remember the 50 character limit on field names ;-). - John. -- John F. Haugh II SNAIL: HECI Exploration Co. Inc. UUCP: ...!ihnp4!killer!jfh 11910 Greenville Ave, Suite 600 "Don't Have an Oil Well? ... Dallas, TX. 75243 ... Then Buy One!" (214) 231-0993 Ext 260