Re: Working with Array of Composite Type

Поиск
Список
Период
Сортировка
От Jan de Visser
Тема Re: Working with Array of Composite Type
Дата
Msg-id 356890269.HF6pRquxC1@wolverine
обсуждение исходный текст
Ответ на Working with Array of Composite Type  (Alex Magnum <magnum11200@gmail.com>)
Ответы Re: Working with Array of Composite Type  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Список pgsql-general
On March 28, 2015 06:18:49 PM Alex Magnum wrote:
> Hello,
> I am struggling with finding the right way to deal with arrays of composite
> types. Bellow is an example of the general setup where I defined an image
> type to describe the image properties. A user can have mulitple images
> stored.

The canonical answer is that in almost all cases where you think you want an
array of composites, you *really* want a table join:

i.e. turn your image *type* into an image *table* with the user_id as a
foreign key.

CREATE TABLE users (
  user_id           serial NOT NULL,
);

CREATE TABLE image (
  id                smallint,
  user_id     int references users (user_id)
  caption           text,
  is_primary        boolean,
  is_private        boolean
);




В списке pgsql-general по дате отправления:

Предыдущее
От: Alex Magnum
Дата:
Сообщение: Working with Array of Composite Type
Следующее
От: Yuri Budilov
Дата:
Сообщение: Re: pgadmin3 installation on Oracle Linux 6.6 64-bit ?