Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.postgresql > #574

Re: Help with 2 table arrays

From Dimitri Fontaine <dimitri@2ndQuadrant.fr>
Newsgroups comp.databases.postgresql
Subject Re: Help with 2 table arrays
Date 2014-05-21 15:58 +0200
Organization A noiseless patient Spider
Message-ID <m2ppj7w7x0.fsf@2ndQuadrant.fr> (permalink)
References <9c29ec52-a5cc-416a-a25a-699a4de140e9@googlegroups.com>

Show all headers | View raw


Tod <socialmediamanagerllc@gmail.com> writes:
> I have two tables, with one containing items in an array. I want to display
> the items in the array which correspond to the other table.

Using an array as storage is a form of denormalisation of the schema.
Did you try with a normalized schema first? What was the problem you did
encounter with using a normalized schema?

> So for the menu id 16, I want to show the names of the dishes 20, 25, 26,
> etc ... in the output.

See the unnest function, then join on its result.

  http://www.postgresql.org/docs/9.3/interactive/functions-array.html

Regards,
-- 
Dimitri Fontaine
PostgreSQL DBA, Architecte

Back to comp.databases.postgresql | Previous | NextPrevious in thread | Find similar


Thread

Help with 2 table arrays Tod <socialmediamanagerllc@gmail.com> - 2014-05-21 06:04 -0700
  Re: Help with 2 table arrays Dimitri Fontaine <dimitri@2ndQuadrant.fr> - 2014-05-21 15:58 +0200

csiph-web