Re: inheritance
От | Shane Ambler |
---|---|
Тема | Re: inheritance |
Дата | |
Msg-id | 45F0843D.5020407@Sheeky.Biz обсуждение исходный текст |
Ответ на | Re: inheritance (chester c young <chestercyoung@yahoo.com>) |
Ответы |
Re: inheritance
|
Список | pgsql-sql |
chester c young wrote: >> --- Greg Toombs <greg.toombs@bluebottle.com> wrote: >> >> >> I'm trying to figure out how to nicely implement a C++ > class-likesystem > > with PostgreSQL. Consider the following: >> Tables Fruit, Apple, Orange > > you can do this traditionally or through pg inheritance, although I do > not think inheritance is well supported before 8.2. Inheritance will most likely fit your C++ class-like system better and will not need foreign keys. Inheritance has been available in postgresql for many years and I think you will find it quite stable. (Not sure if pg6.x had it but it was available in 7.x) Historically a Table in postgresql was called a class (pre-sql) which is still reflected in the system catalogs with pg_class containing the list of tables and other classes like indexes.... http://www.postgresql.org/docs/8.2/interactive/ddl-inherit.html You would then have table fruit as your base class and table oranges that inherits from fruit, giving it all the columns that fruit has plus any that are added to table oranges as well. selecting from table fruit will allow you to get all rows from table apples and table oranges but not the columns unique to the apples or oranges tables. Maybe then you'll add a table basket that has a foreign key to the fruit table....... ;-) -- Shane Ambler pgSQL@Sheeky.Biz Get Sheeky @ http://Sheeky.Biz
В списке pgsql-sql по дате отправления: