Re: designing tables - sidetrack into arrays - Mailing list pgsql-novice

From Andrew Vit
Subject Re: designing tables - sidetrack into arrays
Date
Msg-id A1378D0A-C2C8-11D7-8704-000502742A2D@dihedral.ca
Whole thread Raw
In response to Re: designing tables - sidetrack into arrays  (Cath Lawrence <Cath.Lawrence@anu.edu.au>)
List pgsql-novice
On Wednesday, July 30, 2003, at 12:14  AM, Cath Lawrence wrote:

> OK, a followup to my question now before anyone replies...
>
> On Wednesday, July 30, 2003, at 04:01  PM, Cath Lawrence wrote:
>> Perhaps I should make a special archive table and refer to it by some
>> key. Say, id, [array of archive content file names], bytea for the
>> archive.
>
> Actually this now strikes me as a bad idea, since I think I can't
> search my table by filename to find what archive it's in, and retrieve
> that archive. With a plaintext list I could do
> "select archive from bin_archives where file_name_list like
> ('%my_wanted_file%')"
>
> Or am I being clueless about arrays, too?

This sounds like you want to have a one-to-many relationship between
your record and its associated files. What you need to do is create a
separate table that will reference your record id:

CREATE TABLE associated_files (
   fileid    serial  PRIMARY KEY,
   recordid  int     REFERENCES master_records (id),
   filepath  text    NOT NULL
);

Does that help?

--Andrew Vit


pgsql-novice by date:

Previous
From: Niclas Hedell
Date:
Subject: function that works only once...
Next
From: Tom Lane
Date:
Subject: Re: Unable to start postmaster