Postgres RDBMS/Introduction to PostgreSQL

From Wikibooks, open books for an open world
Jump to: navigation, search

Characteristic features of PostgreSQL[edit]

  • You can define your own types. Just as with tables, types consist of a collection of named attributes so you could define an "employee" type consisting of a text name, an integer employee number and a decimal salary. Unlike tables, you also define input and output functions so that values of your new type can be read and written. It makes sense to ensure that the input function can interpret the values as represented by the output function so that your application can read its own handwriting, but that is not a formal requirement.
  • Inheritance is supported. Suppose you have a table of employees, none of whom currently earn commission. You want to add data about sales representatives to your table, and they will need a commission column. If you add a commission column to your existing employees table, it will always contain NULL in almost every row. Alternatively, you could create a new table just for the sales representatives. It inherits all the columns from the employees table and adds a commission column. PostgreSQL keeps track of the inheritance so you can query all employees (including sales reps), just the standard employees, or just the reps.
  • You can extend it with new functions (including aggregates) and operators. In fact this is essential if you want to support any new types you create beyond simply inputting, storing and retrieving them. User-defined functions are also required if you create your own indexing scheme, another possible consequence of creating new data types.

History of PostgreSQL[edit]

  • Originated from the Ingres project.
  • Post-Ingres project was an attempt to improve the type system.