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 ?


Reply via email to