Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5DGudE02957 for ; Wed, 13 Jun 2001 12:56:39 -0400 (EDT) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.1) with HTTP id 71438 for ; Wed, 13 Jun 2001 09:56:33 -0700 From: "Josh Berkus" Subject: Re: Inheritance - Multiple membership To: pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.4.1 Date: Wed, 13 Jun 2001 09:56:33 -0700 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200106/197 X-Sequence-Number: 3453 Jimmie, > Say I have a tbl_person. tbl_teacher and tbl_student both inherit > from > tbl_person and each have their own extended attributes. Is it > possible for > a person in tbl_person to be both a teacher at the school, and also a > student (say night school or something). Also, the student may be a > part-time employee, like a graduate student. If it is possible, what > would > an insert look like. Given the possibility that someone can exist in > both > tbl_teacher and tbl_student, what happens if you delete their student > record. I'm guessing that it should leave the other records in tact. IMHO, inheritance is *not* the way to do this. What you want relationally is three tables: tbl_people tbl_student_attributes tbl_teacher_attributes Then you can define two views: vw_students tbl_people JOIN tbl_student_attributes vw_teachers tbl_people JOIN tbl_teacher_attributes This way, if a student's teaching assignment ends, you can delete her teacher_attributes while keeping her in the system as a studnet; contrawise, if she quits the institution, you can delete her record in tbl_people and remove her from the system. Further, by defining the triggers to make the views updatable, you can treat them as if they were tables ... e.g. "UPDATE vw_students WHERE ..." This allows you to maintain perfect relational integrity while dealing with the fact that a few individuals are both students and teachers. Fabian Pascal has a whole chapter about how properly designed relational structures make inheritance unnecessary or even hazardous ... see "Practical Issues in Database Design." -Josh Berkus P.S. hey, Tom, do you think that simple views can be made automatically updatable by default someday? version 8.0? ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco