What a relative pronoun does
A relative pronoun (pronombre relativo) joins two statements into one sentence and refers back to a head noun in the main clause. For places (donde) and ownership (cuyo) there are words of their own.
Two sentences become one
que - the all-purpose pronoun
que is the most common relative pronoun, and here Spanish is simpler than English. Where you choose between who, whom, which and that, Spanish uses one word for people and things, subject and object, singular and plural. It never changes, and it stays que between commas too.
Los amigos que tengo son geniales.
The friends I have are great.
La chica que vino ayer es mi prima.
The girl who came yesterday is my cousin.
Mi hermano, que vive en Madrid, es médico.
My brother, who lives in Madrid, is a doctor.
With a preposition - el que and quien
English leaves a preposition dangling at the end: the person I spoke with. Spanish never strands it. The preposition moves to the front of the clause, and que then usually takes the article that matches the head noun.
Preposition + article + que
For people, quien (plural quienes) works too: con quien, a quienes. It agrees in number but not in gender.
La persona con la que hablé era muy amable.
The person I spoke with was very kind.
El libro del que te hablé es de mi padre.
The book I told you about is my father's.
Los amigos con quienes viajo son de Chile.
The friends I travel with are from Chile.