Anyone know how inherited tables are shown on an ERD... both the table
and the connector (if any)?

What I am looking for is how to draw this in the diagram.

Peter

-- 
+---------------------------
| Data Architect
| your data; how you want it
| http://www.codebydesign.com
+---------------------------

Wed, 05 Sep 2001 23:49:21 -0700
Peter Harvey <pharvey@codebydesign.com>
Inherited Table
Peter Harvey wrote:
> 
> Anyone know how inherited tables are shown on an ERD... both the table
> and the connector (if any)?
> 
> What I am looking for is how to draw this in the diagram.

An old S-Designor does it so:
Thu, 06 Sep 2001 12:28:43 +0200
Hannu Krosing <hannu@tm.ee>
Re: Inherited Table
Hannu Krosing wrote:
> 
> Peter Harvey wrote:
> >
> > Anyone know how inherited tables are shown on an ERD... both the table
> > and the connector (if any)?
> >
> > What I am looking for is how to draw this in the diagram.
> 
> An old S-Designor does it so:
> 

Yes. But pgsql does not support multiple inheritance (from what I can
tell) so the extra symbol along the ref line ("can be"/"must be") seems
silly. I am thinking that I should draw the new table slightly diff in
some way just as is done with Views. However; some purests would freak.
<Hmmm>

Thanks

Peter

Thu, 06 Sep 2001 09:08:47 -0700
Peter Harvey <pharvey@codebydesign.com>
Re: Inherited Table
Peter Harvey wrote:
  >Yes. But pgsql does not support multiple inheritance (from what I can
  >tell)...

In fact it does:

  create table child (col1 text) inherits (parent1, parent2);

Identically named and typed columns in the parents are merged.

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Behold, I stand at the door, and knock; if any man 
      hear my voice, and open the door, I will come in to 
      him, and will sup with him, and he with me."       
                                   Revelation 3:20 



Thu, 06 Sep 2001 21:43:20 +0100
"Oliver Elphick" <olly@lfix.co.uk>
Re: Inherited Table 
If I try to get the columns from pg_attribute using the oid of a child
table created with INHERIT I get its columns AND all of its inherited
columns.

How do I just get the columns added by the child table?

I figure I could check each column to see if they also exist in
pg_attribute under a parent table but I figure there must be an
easier/faster way? Another pg_* table perhaps? Besides; I am not certian
this would work if there is a common column between a child and one of
its parents (if that is even allowed)?

As usual, any help would be greatly appreciated.

Peter

BTW: I checked pg_dump source and did not see an answer.

-- 
+---------------------------
| Data Architect
| your data; how you want it
| http://www.codebydesign.com
+---------------------------

Sun, 09 Sep 2001 08:08:56 -0700
Peter Harvey <pharvey@codebydesign.com>
INHERIT
Oliver Elphick wrote:
> 
> Peter Harvey wrote:
>   >If I try to get the columns from pg_attribute using the oid of a child
>   >table created with INHERIT I get its columns AND all of its inherited
>   >columns.
>   >
>   >How do I just get the columns added by the child table?
>   >
>   >I figure I could check each column to see if they also exist in
>   >pg_attribute under a parent table but I figure there must be an
>   >easier/faster way? Another pg_* table perhaps? Besides; I am not certian
>   >this would work if there is a common column between a child and one of
>   >its parents (if that is even allowed)?

hannu=# \d parent 
         Table "parent"
 Attribute |  Type   | Modifier 
-----------+---------+----------
 parid     | integer | not null
Index: parent_pkey

hannu=# create table badchild (parid text) inherits (parent);
NOTICE:  CREATE TABLE: merging attribute "parid" with inherited
definition
ERROR:  CREATE TABLE: attribute "parid" type conflict (int4 and text)
hannu=# 

And anyway, in the current state I would advise you not to put too much 
hope in postgreSQL's OO features, especially inheritance ;)

-------------
Hannu

Sun, 09 Sep 2001 23:23:57 +0500
Hannu Krosing <hannu@tm.ee>
Re: INHERIT
Peter Harvey wrote:
  >If I try to get the columns from pg_attribute using the oid of a child
  >table created with INHERIT I get its columns AND all of its inherited
  >columns.
  >
  >How do I just get the columns added by the child table?
  >
  >I figure I could check each column to see if they also exist in
  >pg_attribute under a parent table but I figure there must be an
  >easier/faster way? Another pg_* table perhaps? Besides; I am not certian
  >this would work if there is a common column between a child and one of
  >its parents (if that is even allowed)?
  >
  >As usual, any help would be greatly appreciated.
  

SELECT a.attname
  FROM pg_attribute AS a,
       pg_class AS c,
       pg_inherits AS i
  WHERE a.attrelid = c.oid AND
        i.inhrelid = c.oid AND
        c.relname = 'child_table'
        AND a.attname NOT IN (
  SELECT a.attname
    FROM pg_attribute AS a,
         pg_class AS c,
         pg_inherits AS i
    WHERE i.inhrelid = c.oid AND
          a.attrelid = i.inhparent AND
          c.relname = 'child_table'
  )


-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Submit yourselves therefore to God. Resist the devil, 
      and he will flee from you."        James 4:7 



Sun, 09 Sep 2001 20:16:00 +0100
"Oliver Elphick" <olly@lfix.co.uk>
Re: INHERIT 