Hi,
just a small hint for folks struggling with relations and stored procedures and stuff. This solved some huge issues for me.
You can do subqueries within the filter query parameter like
id IN (SELECT id FROM table WHERE column = "value")
or in the request uri:
filter=id%20IN%20(SELECT%20id%20FROM%20table%20WHERE%20column%20%3D%20%22value%22)
Greets,
spackmat