Comments on: Putting Analytical Functions to good use – find tables with multiple foreign keys to the same referenced table https://technology.amis.nl/2006/10/11/putting-analytical-functions-to-good-use-find-tables-with-multiple-foreign-keys-to-the-same-referenced-table/ Friends of Oracle and Java Mon, 27 Apr 2015 11:47:05 +0000 hourly 1 http://wordpress.org/?v=4.2 By: Xaprb https://technology.amis.nl/2006/10/11/putting-analytical-functions-to-good-use-find-tables-with-multiple-foreign-keys-to-the-same-referenced-table/#comment-3885 Mon, 16 Oct 2006 14:29:08 +0000 http://technology.amis.nl/blog/?p=1353#comment-3885 For those working on MySQL, I built a similar feature into a Perl script I recently wrote for MySQL. It’s published on MySQL Forge at http://forge.mysql.com/projects/view.php?id=157

]]>
By: Lucas Jellema https://technology.amis.nl/2006/10/11/putting-analytical-functions-to-good-use-find-tables-with-multiple-foreign-keys-to-the-same-referenced-table/#comment-3884 Sun, 15 Oct 2006 15:40:15 +0000 http://technology.amis.nl/blog/?p=1353#comment-3884 Roland,

If all I needed is the name of the table with multiple foreign keys then of course you are right. However, I also want to know the names of the foreign keys. I believe that necessitates the use of the LAG and LEAD functions.

You are right that filtering on constraint_type is not really necessary.

Thanks for your comment.

best regards,

Lucas

]]>
By: Roland Bouman https://technology.amis.nl/2006/10/11/putting-analytical-functions-to-good-use-find-tables-with-multiple-foreign-keys-to-the-same-referenced-table/#comment-3883 Sun, 15 Oct 2006 10:43:33 +0000 http://technology.amis.nl/blog/?p=1353#comment-3883 Hi Lucas,

nice usage of LAG and LEAD. I think these analytical functions are very powerful and quite useful from time to time.

But couldn’t the original problem, “Table Definitions having multiple foreign keys to the same referenced table”, be solved using a simpler (and probably faster) method?

select fk.table_name
from user_constraints fk
, user_constraints pk
where fk.r_constraint_name = pk.constraint_name
and fk.constraint_type = ‘R’
group by fk.table_name
, pk.table_name
having count(*) > 1

(The fk.constraint_type = ‘R’ condition is not really necessary, because r_constraint_name will be NULL for any but foreign key constraints, but it does tend to perform better when it is included)

Roland Bouman

]]>
By: Lucas Jellema https://technology.amis.nl/2006/10/11/putting-analytical-functions-to-good-use-find-tables-with-multiple-foreign-keys-to-the-same-referenced-table/#comment-3882 Thu, 12 Oct 2006 08:44:16 +0000 http://technology.amis.nl/blog/?p=1353#comment-3882 Pete,

Thanks for the compliment and of course you can! I like that.

best regards,

Lucas

]]>
By: Pete_S https://technology.amis.nl/2006/10/11/putting-analytical-functions-to-good-use-find-tables-with-multiple-foreign-keys-to-the-same-referenced-table/#comment-3881 Wed, 11 Oct 2006 18:43:09 +0000 http://technology.amis.nl/blog/?p=1353#comment-3881 Lucas
A nice example; can I cite it my beginers giude to Analytics paper at UK OUG in November?

]]>