X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BB1683A3F35 for ; Tue, 16 Nov 2004 18:50:19 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43452-09 for ; Tue, 16 Nov 2004 18:50:13 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id AB7BE3A3F3E for ; Tue, 16 Nov 2004 18:50:12 +0000 (GMT) Received: (qmail 19746 invoked from network); 16 Nov 2004 19:50:32 +0100 Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) by boutiquenumerique.com with SMTP; 16 Nov 2004 19:50:32 +0100 Date: Tue, 16 Nov 2004 19:51:31 +0100 To: pgsql-sql@postgresql.org Subject: Re: tree structure photo gallery date quiery References: <200411161129.46131.gary.stainburn@ringways.co.uk> From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <200411161129.46131.gary.stainburn@ringways.co.uk> User-Agent: Opera M2/7.54 (Linux, build 751) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/152 X-Sequence-Number: 19471 > I'm looking at the possibility of implementing a photo gallery for my > web site with a tree structure, something like: You don't really want a tree structure, because one day you'll want to put the same photo in two galleries. Suppose you take a very interesting photo of celery during your trip to china, you might want to create a 'Trip to China' folder, and also a 'Celery' folder for your other celery photos... well, if you don't like vegetables, it also works with people, moods, geographic regions, themes, etc. You could define this structure : You could then define tables describing themes, and/or keywords, link photos with these themes and keywords, and define a folder as either being a specific collection of photos, or as a collection of one or several themes. From a tree, it becomes a bit more like a graph. Themes can also be organized and relationed together. This opens the path to easy searching and cataloguing ; is not that much more difficult to do, and in the end you'll have a much better system. > How would I go about creating a view to show a) the number of photos in > a gallery and b) the timestamp of the most recent addition for a > gallery, so that it interrogates all sub-galleries? If you're concerned about performance, you should do this in a materialized view updated with triggers. If you can afford a seq scan on every time, a few stored procs should do the trick.