How do I count the number of different child id's belonging to a parent record?
There are various ways to solve this problem, but with a composite index on (album_id, artist_id) most DBMS will manage to use only this index (a full index scan) with the following query and thus be quite efficient:

SELECT album_id
FROM track
GROUP BY album_id
HAVING MIN(artist_id) &lt; MAX(artist_id) ;


If you also want the number of artists per album, you can add COUNT(DISTINCT artist_id) in the select list.



A less obfuscated alternative condition is to use (which could be less efficient than the above MIN &lt; MAX method):

HAVING COUNT(DISTINCT artist_id) &gt; 1 ;