Multiple inserts into 2 tables with FKs - Mailing list pgsql-novice

From Tiemo Kieft
Subject Multiple inserts into 2 tables with FKs
Date
Msg-id 468A222C.6050305@gmail.com
Whole thread Raw
Responses Re: Multiple inserts into 2 tables with FKs
List pgsql-novice
Hi

I have 2 tables, one containing unique filenames, the other containing
paths to those files. Paths are spread over multiple hosts (SMB shared
files). The layout is like this:

    Column       |          Type          |
Modifiers
---------------+------------------------+-----------------------------------------------------------------
 filename_id   | integer                | not null default
nextval('filenames_filename_id_seq'::regclass)
 filename_name | character varying(512) |
Indexes:
    "filenames_pkey" PRIMARY KEY, btree (filename_id)
    "filenames_filename_name_key" UNIQUE, btree (filename_name)

      Column      |          Type           |
Modifiers
------------------+-------------------------+---------------------------------------------------------
 path_id          | integer                 | not null default
nextval('paths_path_id_seq'::regclass)
 path_filename_id | integer                 |
 path             | character varying(2048) |
Foreign-key constraints:
    "paths_path_filename_id_fkey" FOREIGN KEY (path_filename_id)
REFERENCES filenames(filename_id)

The thing is, these tables will be update regularly (once a day, at
least). All hosts on this SMB network are indexed, their files and paths
added to the database if they aren't there already. My question is, how
do I actually go about doing this? How do I find out which filename_id
to insert into the paths table?

Greetings,
Tiemo.


pgsql-novice by date:

Previous
From: "Loredana Curugiu"
Date:
Subject: dblink inside plpgsql function
Next
From: "Loredana Curugiu"
Date:
Subject: Re: [SQL] dblink inside plpgsql function