News for hackers. Stuff that matters.
Re:A Simple Guide to Five Normal Forms in Relational Databas... by yangyang on Monday September 29, 2014 @10:27AM (#8382953)
> Or if you're using Postgres, you can return the metadata as an associative array. E.G. http://stackoverflow.com/a/11942726

That's not an associative array, it's just an array of a composite type. The hstore type is probably the closest you'd get to an associate array in PostgreSQL, but the keys and values are always strings.

Re:A Simple Guide to Five Normal Forms in Relational Databas... by dragonwriter on Monday September 29, 2014 @01:03PM (#8383783)
> The hstore type is probably the closest you'd get to an associate array in PostgreSQL

No, a table (possibly a temp table with the results of a particular query) with an appropriately defined primary key (or other unique index) would be the closest you can get to an associative array -- since a relation with n candidate keys is exactly identical to n different associative arrays with the same data but different key/value splits.

But an array of a composite type drawn in such a way that some set of columns is guaranteed unique is pretty much the same thing from a data perspective, even though you may need to do work on the client side to load it into a structure that supports associative array operations (e.g., efficient key/value lookups).

Re:A Simple Guide to Five Normal Forms in Relational Databas... by yangyang on Monday September 29, 2014 @01:19PM (#8383853)
I meant as a self-contained type. PostgreSQL doesn't support nested tables.

The "associative" in associative array implies association is a property of the data structure, not the way you happen to be using it.

Re:A Simple Guide to Five Normal Forms in Relational Databas... by jimktrains2 on Monday September 29, 2014 @11:21AM (#8383277)
It's returning a record, which is more of a struct than an array.
Re:A Simple Guide to Five Normal Forms in Relational Databas... by yangyang on Monday September 29, 2014 @12:51PM (#8383728)

  CREATE OR REPLACE FUNCTION get_people()
      RETURNS person[]  LANGUAGE sql AS
person is a composite type, defined further up. The square brackets indicate an array of that type.
Re:A Simple Guide to Five Normal Forms in Relational Databas... by jimktrains2 on Monday September 29, 2014 @02:01PM (#8384143)
I misread you at first.