In this post, I understood that verbs determine the case of nouns and prepositions determine case of prepositional objects. And in this answer, the three group of relative pronoun is discussed.
My question is, how do we figure out what is the case of a relative pronoun when writing a German sentence? I can't see how can one extrapolate the idea in the first post to this one.