Relative clauses with prepositions

Relative clauses are subordinate clauses that provide more information about a noun or a pronoun in the main clause. In other words, they refer to a word in the main clause - the antecedent.

Relative clauses are introduced by relative pronouns. The pronoun's number and gender are determined by the word it links back to in the main clause.

Examples: 

Das ist der Bauer. Er hat viele Tiere
Das ist der Bauer, der viele Tiere hat

Das ist der Pullover. Der Bauer gibt ihn Harry.
Das ist der Pullover, den der Bauer Harry gibt. 

If a preposition must be used to connect the antecedent and verb in the subordinate clause, then the preposition must precede the relative pronoun in the relative clause. The preposition determines the case of the relative pronoun.

Relative clauses that feature the preposition "mit" require the dative.

Examples:

Das ist eine Maschine. Der Bauer melkt die Kühe mit der Maschine.
Das ist eine Maschine, mit der der Bauer die Kühe melkt.

Das ist ein Pferd. Der Bauer redet gern mit dem Pferd.
Das ist ein Pferd, mit dem der Bauer gern redet.

More:

Relative clauses can be constructed with other dative prepositions as well.

Example:

Ist das der Mann? Sie haben von dem Mann gesprochen.
Ist das der Mann, von dem Sie gesprochen haben?

They can also feature accusative prepositions.

Examples:

In dem Stall stehen viele Kühe. Harry und der Bauer gehen in den Stall.
In dem Stall, in den Harry und der Bauer gehen, stehen viele Kühe.

Julia ist Harrys Freundin. Er kann ohne sie nicht leben.
Julia ist Harrys Freundin, ohne die er nicht leben kann.

Die Zeitschleife ist ein Thema. Harry möchte gerne über das Thema sprechen.
Die Zeitschleife ist ein Thema, über das Harry gerne sprechen möchte.