The relative pronouns all refer to something either previously stated or understood and thus are related to that reference. There are two different kind of clauses that are important to understand to be able to find the correct pronouns.
Restrictive clauses: these clauses contain information that is essential to the meaning of the sentence .If clauses were removed the sentence either would change meaning of become meaningless or ridiculous.
Example: Spanish lessons that are given by a bad teacher are useless.
Nonrestrictive clause: these clauses contain information that I usually helpful to the overall meaning of the sentence however it is not essential it this clause were removed the sentence would stand on its own.
Cats which sometimes live fifteen years or longer make nice pets.
I. The use of que in clauses.
The relative pronouns that separate clauses and mean “that,” “who,” and “which,” in English all translate as que in Spanish. There is no distinction between people (who) and animals and thing (that/which) referents as there is in English in this context.
This pronoun “que” sets up both restrictive & nonrestrictive clauses. Note that in English the relative pronoun is sometimes omitted. In Spanish this is not possible: you must include “que”.
El caballo que gana la carrera/ The horse that wins the race
Los estudiantes que leen el capitulo/ The students who read the chapter
II. The use of cual or el que in Clauses.
When the relative pronouns that, which, who or whom introduce a nonrestrictive clause (information not essential to the overall meaning of the sentence), you can use el cual, los cuales, las cuales) or el que (la que, los que, las que) instead of the simple que.
Tu hermana, la cual/la que gana mucho dinero, vive en una casa muy grande y bonita.Estas fresas, las cuales /las que son de Boquete, estan muy frescas.
III. The use of a preposition + quien or que.
When the relative pronoun is the object of a preposition, you will use the appropriate preposition + quien, when the reference is a person, or the preposition + que, when the referent is an animal or a thing. A clause formed by the preposition + quien or que is a restrictive clause (its information is essential to the meaning of the sentence).
El es el hombre con quien trabajo. He is the man I work with./
He is the man with whom I work.
Iris y Carol son las chicas Iris and Carol are the girls whom I know.
A quienes conozco.
Este es el libro en que pienso. This is book that I’m thinking about./
This the book about which I’m thinking.
IV. The use of lo que.
Lo que, which means “that which”, or “whatever” is a neuter relative pronoun that allow to refer to great abstraction, as in “You can have whatever you want”; or to encompass the entirety of something that is said or done, as in “what you are doing is a sin.”
Note that when lo que is used to mean “whatever” it often stands for something that is unknown or doubtful Haz lo que Piedas. (Puedas is a subjunctive form ) (Do whatever you can).
Lo que dices es interesante. What you’re saying is interesting.
Tienen lo que necesito? Do you have what I need?
El siempre hace lo que quiere. He always does whatever he wants.
V. The use of cuyo, cuya, cuyos, cuyas.
This relative pronoun (which means “whose”) separates the owner and that which is owned. “Peter, whose basis is brilliant, is a fascinating man.” In this sentence. Peter is the owner and the thesis is the object owned. The word whose begins the clause, and the form of cuyo must must agree with the noun that immediately follows it.
Pedro, cuya tesis es brillante,es un hombre fascinante.
George, cuyos abuelos son musicos profesionales, toca bien el piano.