How can I ensure a new record contains values that refer to a schema, table, and column that currently exist in the database?
For example, given a table:
CREATE TEMP TABLE "column_reference" (
"gid" SERIAL PRIMARY KEY
, "val" INTEGER
, "schema" TEXT
, "table" TEXT
, "column" TEXT
);
how can I ensure schema.table.column exists?
I tried a fkey to information_schema.columns, but, of course, foreign keys to views are disallowed.
It also appears from the columns view definition that I need several tables in order to get the schema, table, and column names so I can't create a single foreign key to the source tables.
My current workaround is to manually create a __columns table from the information_schema.columns view and reference it instead. This works given the control I happen to have on this project at this point in time, but am looking for a permanent, dynamic solution.
Is there a different constraint or method I could use?