Subject | Re: [firebird-support] Dependencies |
---|---|
Author | Milan Babuskov |
Post date | 2006-03-30T19:08:19Z |
Alan McDonald wrote:
check constraints and computed columns. You need to take all of those
into account.
Here's what we use in FlameRobin:
1. get deps. based on foreign keys
2. deps. for computed columns (join rdb$dependecies with rdb$relations)
3. deps. based on check constraints
Checks are enforced via system triggers, so:
a) find all check constraints for a table
b) find all system triggers bound to that CHECK constraint
c) find dependencies for those system triggers
d) use those dependencies as deps. of this table
In case you wish to see the queries involved, the code for it is in file
metadataitem.cpp in function: MetadataItem::getDependencies, here:
http://svn.sourceforge.net/viewcvs.cgi/flamerobin/trunk/flamerobin/src/metadata/metadataitem.cpp?view=markup&rev=817
Watch the long-line wraps.
--
Milan Babuskov
http://swoes.blogspot.com/
http://www.flamerobin.org
> IBExpert (and others) can show a tables dependenciesIt's not simple. Tables can relate with other tables on foreign keys,
> I'm interested only in a table's dependence on other tables.
> RDB$DEPENDENCIES only lists a tables dependence on triggers and views but
> not other tables. There must be a more circuitous route to obtaining the
> number of tables a table is dependent on.
> Anyone know the SQL?
check constraints and computed columns. You need to take all of those
into account.
Here's what we use in FlameRobin:
1. get deps. based on foreign keys
2. deps. for computed columns (join rdb$dependecies with rdb$relations)
3. deps. based on check constraints
Checks are enforced via system triggers, so:
a) find all check constraints for a table
b) find all system triggers bound to that CHECK constraint
c) find dependencies for those system triggers
d) use those dependencies as deps. of this table
In case you wish to see the queries involved, the code for it is in file
metadataitem.cpp in function: MetadataItem::getDependencies, here:
http://svn.sourceforge.net/viewcvs.cgi/flamerobin/trunk/flamerobin/src/metadata/metadataitem.cpp?view=markup&rev=817
Watch the long-line wraps.
--
Milan Babuskov
http://swoes.blogspot.com/
http://www.flamerobin.org