| From: | JanWieck(at)t-online(dot)de (Jan Wieck) | 
|---|---|
| To: | Ian Turner <vectro(at)pipeline(dot)com> | 
| Cc: | Oliver Elphick <olly(at)lfix(dot)co(dot)uk>, pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: Inheritance | 
| Date: | 2000-07-30 11:48:04 | 
| Message-ID: | 200007301148.NAA06541@hot.jw.home | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
Ian Turner wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> > `SELECT * FROM Entities*;'
> >
> > up to and including 7.0.x.
> >
> > In 7.1, I believe a select on the parent will automatically show the
> > children and you will need to do something like `SELECT * FROM ONLY Entities'
> > to exclude descendant tables.
>
> Yes, but what about referential integrity? Can I have a table column
> reference a column from Entities*? In my experimentation, this is not the
> case.
    Referential integrity doesn't work with inheritance, and will
    not in 7.1.
    It isn't possible to put a unique constraint on a  column  of
    Entities*  (AFAIK).  So that a SELECT pkey FROM Entities will
    never  return  any  duplicates?  The  RI  implementation   of
    PostgreSQL  doesn't  insist  on  such  a unique constraint to
    exist up to now, but it is required by the SQL specs and thus
    we'll do so someday.
        pgsql=# create table t1 (pkey integer primary key);
        NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index 't1_pkey' for table 't1'
        CREATE
        pgsql=# create table t2 (val integer) inherits (t1);
        CREATE
        pgsql=# insert into t1 values (1);
        INSERT 21274 1
        pgsql=# insert into t2 values (1, 11);
        INSERT 21275 1
        pgsql=# select * from t1;
         pkey
        ------
            1
            1
        (2 rows)
Am I missing something here?
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck(at)Yahoo(dot)com #
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Reuven M. Lerner | 2000-07-30 14:26:38 | Better error messages from JDBC | 
| Previous Message | Ian Turner | 2000-07-30 06:44:41 | Re: Inheritance |