chester c young wrote:
--- Greg Toombs <[EMAIL PROTECTED]> 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
[EMAIL PROTECTED]

Get Sheeky @ http://Sheeky.Biz

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to