Search Postgresql Archives

stored function data structures - difficulty

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




I cannot find a way to programatically:
1. Given a table name, find all foreign key fields in the given table by field name (column name) 2. Given a single foreign key field name, programatically look up the corresponding reference table name and the reference primary key field

so have thought of simply hard coding this (for 100 tables).

What Kind of data structure could I use that is available to me that would hold as the key the table name and from there be able to iterate through and get all foreign keys by field name and from there another inner loop that would give me another key/value pair of the table name (key) and the primary key (value) that corresponds to that foreign key?

I want to hard code all of this information into a data structure and iterate through at some point in another function.

Instead of discovering this programatically, I can manually look at each table / schema diagram and hard code it, but I really need one super structure that will hold as keys every table in the schema and be able to drill down that that tables foreign keys and from there further drill down to get the table name, primary key field in that table.

I have seen a number of structures that might work, but cannot find an example on how to actually use for what I need to do. If you do have an idea of a structure, it would be great and awesome if I could be pointed to an actual working example that I could test in a sandbox first to understand how it works.

thanks


J.V.


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux