pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedInheritance - Multiple membership
2+ messages / 2 participants
[nested] [flat]
* Inheritance - Multiple membership
@ 2001-06-12 21:15 Jimmie Fulton <JFulton@ehso.emory.edu>
0 siblings, 1 reply; 2+ messages in thread
From: Jimmie Fulton @ 2001-06-12 21:15 UTC (permalink / raw)
To: pgsql-sql
This question was asked in 1998 on this list by someone else, but did not
appear to be answered...
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.
Any ideas?
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Inheritance - Multiple membership
@ 2001-06-13 16:56 Josh Berkus <josh@agliodbs.com>
parent: Jimmie Fulton <JFulton@ehso.emory.edu>
0 siblings, 0 replies; 2+ messages in thread
From: Josh Berkus @ 2001-06-13 16:56 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-06-13 16:56 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-06-12 21:15 Inheritance - Multiple membership Jimmie Fulton <JFulton@ehso.emory.edu>
2001-06-13 16:56 ` Josh Berkus <josh@agliodbs.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox