Re: Re: Problem with inheritance - Mailing list pgsql-general

From Marc SCHAEFER
Subject Re: Re: Problem with inheritance
Date
Msg-id Pine.LNX.3.96.1010127092106.1091A-100000@defian.alphanet.ch
Whole thread Raw
In response to Re: Problem with inheritance  (Alfonso Peniche <alfonso@iteso.mx>)
Responses Search engine doesn't work
List 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 ?



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: 2 or more columns of type 'serial' in a table
Next
From: "Oliver Elphick"
Date:
Subject: Re: get last sequence