Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id D77A59FA182 for ; Tue, 24 Jul 2007 11:15:13 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 62994-01-2 for ; Tue, 24 Jul 2007 11:14:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from oxford.xeocode.com (unknown [62.232.55.118]) by postgresql.org (Postfix) with ESMTP id D44529F9B25 for ; Tue, 24 Jul 2007 11:10:46 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=oxford.xeocode.com) by oxford.xeocode.com with esmtp (Exim 4.67) (envelope-from ) id 1IDL64-0003OA-Vc for pgsql-sql@postgresql.org; Tue, 24 Jul 2007 15:10:45 +0100 From: Gregory Stark To: pgsql-sql@postgresql.org Subject: Re: is there a 'table' data type in pg? In-Reply-To: <20070724124246.GA22602@apartia.fr> (Louis-David Mitterrand's message of "Tue, 24 Jul 2007 14:42:46 +0200") Organization: EnterpriseDB References: <20070724124246.GA22602@apartia.fr> X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX.sql" 638) Date: Tue, 24 Jul 2007 15:10:44 +0100 Message-ID: <87sl7d28pn.fsf@oxford.xeocode.com> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/139 X-Sequence-Number: 28874 "Louis-David Mitterrand" writes: > Can I use a another column to store the type of the id_subject (ie: the > tabled it belongs to) ? Then I would be able to query that table for > additional info to print alongside the forum posts. There are ways to identifier tables in Postgres but there's no way to run a query against a table using them. I would strongly recommend you define your own list of "object_types", probably even have an object_type table with a primary key, a description column, and a table_name column. Then you can in your application construct the appropriate query depending on the object_type. One alternative you could do is have a set-returning plpgsql function which has a big if statement and performs the right kind of query. I think the records would have to all be the same -- they can't be different kinds of records depending on the type of object. -- Gregory Stark EnterpriseDB http://www.enterprisedb.com