Re: Re: Problem with inheritance

From: Marc SCHAEFER <schaefer(at)alphanet(dot)ch>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Re: Problem with inheritance
Date: 2001-01-27 08:26:46
Message-ID: Pine.LNX.3.96.1010127092106.1091A-100000@defian.alphanet.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 26 Jan 2001, Alfonso Peniche wrote:

> I like the idea, there's just one problem, a user can be both a student and an
> employee...

- If the guy is an user only, then just fill the user template
- If the guy is a student, add a tuple to the is_student relation.
- If the guy is an employee, add a tuple to the is_employee relation.

You do not need to delete the is_student if you insert into is_employee
(and backwards).

The only problem that I see with my approach is that you can create an
user which isn't neither a student nor an employee: if this is an issue
you might want to
periodically run a query like:

SELECT u.*
FROM user u
WHERE (u.id NOT IN (SELECT user_id FROM is_student))
AND (u.id NOT IN (SELECT user_id FROM is_employee))

to spot illegal entries.

(haven't tried it, though).

Or someone from the PostgreSQL or SQL experts could tell us if there is a
way to do cross-table integrity checking ?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Oliver Elphick 2001-01-27 10:05:21 Re: get last sequence
Previous Message Tom Lane 2001-01-27 07:27:04 Re: 2 or more columns of type 'serial' in a table