Inheritance is a concept from object-oriented databases. It
opens up interesting new possibilities of database design.

Let's create two tables: A table cities and a table capitals. Naturally, capitals are also cities,
so you want some way to show the capitals implicitly when you
list all cities. If you're really clever you might invent some
scheme like this:

In this case, a row of capitalsinherits all columns (name, population,
and altitude) from its parent, cities.
The type of the column name is
text, a native PostgreSQL type for variable length
character strings. State capitals have an extra column,
state, that shows their state. In
PostgreSQL, a table can inherit
from zero or more other tables.

For example, the following query finds the names of all
cities, including state capitals, that are located at an altitude
over 500 feet:

Here the ONLY before cities indicates that the query should be run over
only the cities table, and not
tables below cities in the
inheritance hierarchy. Many of the commands that we have already
discussed — SELECT, UPDATE, and DELETE —
support this ONLY notation.

Note: Although inheritance is frequently useful, it
has not been integrated with unique constraints or foreign
keys, which limits its usefulness. See Section 5.8 for more detail.