Subject | Re: [ib-support] Firebird mention |
---|---|
Author | Raul Chirea |
Post date | 2002-08-02T03:43:01Z |
Hi,
I can see that you don't know much about Postgres model of table
inheritance.
This model does not break in any way data integrity or relational model.
Primary key _instance_ is the same for the base table and it's derived
tables. When you select from a table the results will include _child_tables_
also. This is a very interesting feature because you can enforce uniqueness
to more than one table, like this:
create table docs (
id integer not null,
title varchar(128),
body_text varchar(16000),
primary key (id)
);
create table docs_with_header (
header varchar(16000)
) inherites (docs);
create table docs_with_footer (
footer varchar(16000)
) inherits (docs);
After that you can select:
select id, title from docs; -- will give all docs including child tables
select id, title from only docs; -- will give docs in table "docs" only
select id, title, header, body_text from docs_with_header; -- will give rows
in "docs_with_header" table
... and so on !
I agree that this type of inheritance is not needed too often but sometimes
is very usefull ! It can be substituted with classic RDBMS techniques but it
nice to have it !
Raul.
I can see that you don't know much about Postgres model of table
inheritance.
This model does not break in any way data integrity or relational model.
Primary key _instance_ is the same for the base table and it's derived
tables. When you select from a table the results will include _child_tables_
also. This is a very interesting feature because you can enforce uniqueness
to more than one table, like this:
create table docs (
id integer not null,
title varchar(128),
body_text varchar(16000),
primary key (id)
);
create table docs_with_header (
header varchar(16000)
) inherites (docs);
create table docs_with_footer (
footer varchar(16000)
) inherits (docs);
After that you can select:
select id, title from docs; -- will give all docs including child tables
select id, title from only docs; -- will give docs in table "docs" only
select id, title, header, body_text from docs_with_header; -- will give rows
in "docs_with_header" table
... and so on !
I agree that this type of inheritance is not needed too often but sometimes
is very usefull ! It can be substituted with classic RDBMS techniques but it
nice to have it !
Raul.