Re: Using meta-data for foreign key? - Mailing list pgsql-general

From Mike Blackwell
Subject Re: Using meta-data for foreign key?
Date
Msg-id 48077B9C.6000908@sbcglobal.net
Whole thread Raw
In response to Re: Using meta-data for foreign key?  (Erik Jones <erik@myemma.com>)
Responses Re: Using meta-data for foreign key?  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Using meta-data for foreign key?  ("Roberts, Jon" <Jon.Roberts@asurion.com>)
List pgsql-general
More detail, as suggested.

I have an existing table in an app, along the lines of:
>>
>> CREATE TABLE foo (
>>  name text,
>>  address text,
>>  some_numeric_info integer,
>>  <a bunch of additional fields here>
>> );
>>


I essentially need another table

CREATE TABLE foo_printing_options (
  field_name text,
  print_order int not null,
  suppress boolean not null,
  <a couple additional options here>
);


The values of field_name in foo_printing_options would be the individual
field names in foo (i.e. name, address, etc).   foo_printing_options
would be available to the user via the app to allow them to specify
report layout.

My question, then, is if it considered acceptable practice to, instead
of having field_name in the secondary table, have a foreign key
reference back to the field definition in the meta-data.  This would
allow the app to be less sensitive to schema changes (fairly common).

Is linking to the metadata from the app tables directly bad?  Unsafe?  Ok?


pgsql-general by date:

Previous
From: Ottavio Campana
Date:
Subject: problem with tsearch and utf-8 on postgresql 8.1
Next
From: Tom Lane
Date:
Subject: Re: Using meta-data for foreign key?