Re: Help with Arrays and References

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: "William N(dot) Zanatta" <william(at)veritel(dot)com(dot)br>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Help with Arrays and References
Date: 2002-06-25 00:25:43
Message-ID: 20020624172038.P61359-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 24 Jun 2002, William N. Zanatta wrote:

> Hi,
>
> I'm starting on PostgreSQL so please be patient; =]
>
> I'm building a book library database in which I have a table
> TBL_FORMAT which keeps basic information on various file-formats (ie 1,
> PDF, Portable Document Format) and a TBL_BOOKS which I want to reference
> TBL_FORMAT. But the column Format inside TBL_BOOKS is an array, as a
> book may exist in one or more file types. My doubt is: If I make
> something like
>
> CREATE TABLE "tbl_books" (
> "id_book" int4 DEFAULT nextval('TBL_Books_ID_Books_Seq'::text) NOT NULL,
> "format" _int4 NOT NULL REFERENCES TBL_Format ON_UPDATE CASCADE,
> ...
>
> will the CASCADE action update my TBL_Books (Format) keeping the
> other values in the array or will it erase all and set the new Format value?

That shouldn't even be legal assuming that tbl_format's key is an int.
The two types must be comparable which isn't true of int4 and _int4.
You're probably better off with a details table with the book's id and
format's id and appropriate references.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2002-06-25 00:28:10 Re: calling a plpgsql procedure
Previous Message Kurt at iadvance 2002-06-25 00:08:54 Re: Some Solaris notes, and an invitation