Bug #7409 InnoDB: function to count usage of a key as foreign key in the child tables
Submitted: 18 Dec 2004 18:05 Modified: 13 May 2010 16:04
Reporter: Zrin Ziborski Email Updates:
Status: Open Impact on me:
Category:MySQL Server: InnoDB storage engine Severity:S4 (Feature request)
Version: OS:
Assigned to: Assigned Account CPU Architecture:Any

[18 Dec 2004 18:05] Zrin Ziborski
It would be helpful to have functions like IS_USED() and/or USE_COUNT() that would tell if a value of (primary) key is used in any child table and how often it is used, respectively.

in child table(s):
	FOREIGN KEY (some_field) REFERENCES film(flm_id)
for parent table `film`
	SELECT USE_COUNT(flm_id) FROM film;
for each row it would return the count of child rows referencing it.

How to repeat:
not applicable (feature request)

Suggested fix:
the functionality is already implemented, it seems that it is just needed to expose this functions in the API (i.e. as SQL extension).