3 ms·
What is "relations as types"? I googled to no avail.
by egeozcan 11y ago
What is "relations as types"? I googled to no avail.
- icebraining 11y agoRelations are tables, indexes, views, etc. When you create one, PG will also create a composite data type[1] that corresponds to one of its rows. And you can use those types in interesting ways - for example, you can have a column in a table that stores a complete composite value. [1] http://www.postgresql.org/docs/9.3/static/rowtypes.html http://www.postgresql.org/docs/9.3/static/rowtypes.html
- sbuttgereit 11y agoYes, this is exactly why I think a guide examining such a topic would be good. You get a doc page for it (see icebraining's comment), but that's about it. Performance gets covered often, thinking about how to get the most of PostgreSQL's type system doesn't. I don't really use this feature to drive structure (really at all), but do use it extensively when programming functions in PL/pgSQL. I also exploit this in queries sometimes as well. It's not a life changing feature to be sure, but it is relatively unique and can help solve problems that are more cumbersome to solve without the feature.