X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AD208D914B for ; Tue, 20 Sep 2005 09:16:33 -0300 (ADT) 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 26260-08 for ; Tue, 20 Sep 2005 12:16:27 +0000 (GMT) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by svr1.postgresql.org (Postfix) with ESMTP id 2627FD90EC for ; Tue, 20 Sep 2005 09:16:27 -0300 (ADT) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id j8KC9L2n016656 for ; Tue, 20 Sep 2005 15:09:21 +0300 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id j8KC9KFf016652 for ; Tue, 20 Sep 2005 15:09:21 +0300 Date: Tue, 20 Sep 2005 15:09:20 +0300 (EEST) From: Achilleus Mantzios To: pgsql-sql@postgresql.org Subject: Re: Inheritance (general hints wanted) In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.009 required=5 tests=[AWL=0.009] X-Spam-Level: X-Archive-Number: 200509/176 X-Sequence-Number: 22723 O Achilleus Mantzios έγραψε στις Sep 20, 2005 : > > Hi, > > I think i have reached a point in my PgSQL years > that i am seriously thinking of using inheritance. > > The situation is simple: An new entity (tanker vessels crew) > is about to be modeled, and i suspect > there will be a future need to include > the rest of 'workers' besides 'sailors', > IOW i suspect a future need to generalize. > > So i am thinking of a two-level tree hierarchy, > where there is a simple table emp (employee), > and a direct child 'tankerscrew'. Later > there may be 'masons', 'office_employees' > and so on. Each table may be managed by its own applications, whereas the accounting software will only need to read and *update* the generic top level 'employee' table. That would be great but unfortunately it isnt how it works in PostgreSQL currently... If PRIMARY KEYS were to be shared, a great future (real) feature would be a "isinstanceof" -like function on the PRIMARY KEY, which tells if a row of the specific PK is from a certain table in the hierarchy. > > The problem is that while i find this approach > attractive, i have never used PostgreSQL > inheritance exhaustively and in production scale. > > Furthermore, i also feel that not many > people have used inheritance in a massive fashion > (besides playing with a test db). > > Of course i can do it with separate uncoupled tables, > that can be later related with some views. > > So that leads to the final question: > -What are the main PROs of inheritance that cant be beat > by other solutions, and > -Are there any traps someone must have in mind when he > prepares for such a design? > > Thanx in advance. > -- -Achilleus