How do you determine the case of relative clauses (Relativsätze)?
I'm having trouble understanding how to determine whether a relative clause is in the nominative, accusative, dative, or genitive case.
I know that in some sentences I can look for certain key words within the sentence that indicate the case (i.e. words like durch, für, gegen, ohne, um indicate the accusative case). However, I don't know how to deal with complex sentences that use relative clauses.
For example, the book I'm currently reading says that the article" dem" in the sentence "Das ist das Kind, dem ich geholfen habe." is an example of the dative being used. But why is that? I don't understand how I would know that.
Another example is "Das is Peter, den ich noch aus der schule kenne." Here, the book says that "den" is used due to the accusative case. But again, I don't understand why that is. I see the word "aus" in the sentence, so why is it accusative instead of dative? I'm confused.
Can someone who has a good understanding of German grammar please explain this to me?