Relative clauses are used to tell us which person or thing we are talking about. It makes it possible to give more Information about the person or thing being spoken about. Ex: “The boy has gone into hospital, he lives near my house.” => “The boy who lives near my house has gone into hospital”. The book is very good I bought it yesterday. => The book which I bought yesterday is very good.
We use “who” to refer to people, “which” to refer to things. Which can be used to refer to the whole previous sentence or idea. Ex: I passed my driving test, which surprised everyone.
We use “whose” to refer to someone’s possessions. Ex: That’s the woman whose son won the lottery.
We can use “where” to refer to places. Ex: the hotel where I stayed was right on the beach.
Note: Defining relative clauses (DRC) qualify a noun, and tell us exactly which person or thing is being referred to. There is no comma before a defining relative clause. Ex: she likes people who are good fun to be with. (She likes people on its own: doesn’t mean very much; we need to know which people she like).
Notice how we can leave out the relative pronoun if it is the object of the relative clause. Ex: Did you like the present I gave you?
We are not leave out the pronoun if it is the subject of the clause. Ex: I met a man who works in advertising.
Prepositions usually come at the end of the relative clause. Ex: She is a friend I can always rely on.
Note: Non-defining relative clauses (NDRC) add secondary Information to a sentence, almost as an afterthought. Ex: my friend Tom, who is England, plays the football. (My Friend Tom is clearly. We don’t need to know which Tom is being discussed. The clause “who is England” gives us extra Information about him).
Relative pronoun cannot be left out of NDRC. Ex: Paul, who has written several books, addressed the meeting.

Note:
– Propositions can come at the end of the NDRC. In a more formal written style, propositions came before the pronoun. Ex: he talked about theories of market forces, which I’d never even heard of.
– DRC is much more common in the spoken language, and NDRC are more common in the written language. Ex: My friend Tom, who is England, plays the football. By the way.

Who

Used to show which person or people you mean: The people who called yesterday want to buy the house. The people (who) we met in France have sent us a card.
Used to give more Information about sb: Mrs Smith, who has a lot of teaching experience at junior level, will be joining the school in September. And then Mary, who we had been talking about earlier, walked in.

Whom

Used instead of “who” as the object of a verb or preposition: Whom did they invite? To whom should I write? The author whom you criticized in your review has written a reply. Her mother, in whom she confided, said she would support her unconditionally.
The use of “whom” as the pronoun after prepositions is very formal: To whom should I address the letter? He asked me with whom I had discussed it. In spoken English it is much more natural to use who and put the preposition at the end of the sentence: Who should I address the letter to?
In defining relative clauses the object pronoun “whom” is not often used. You can either use who or that, or leave out the pronoun completely: The family (who / that / whom) I met at the airport were very kind.
In non-defining relative clauses who or, more formally, whom (but not that) is used and the pronoun cannot be left out: Our doctor, who / whom we all liked very much, retired last week. This pattern is not used very much in spoken English.

Whose

Whose is not usually used to refer a thing, “of which” is usually used instead.
Used in questions to ask who sth belongs to: Whose house is that? I wonder whose this is.
Used to say which person or thing you mean: He’s a man whose opinion I respect. It’s the house whose door is painted red.
Used to give more Information about a person or thing: Isobel, whose brother he was, had heard the joke before.

Which

Used to be exact about the thing or things that you mean: Houses, which overlook the lake, cost more. It was a crisis for which she was totally unprepared.
Note: That can be used instead of which in this meaning, but it is not used immediately after a preposition: It was a crisis that she was totally unprepared for.
Used to give more Information about sth: His best movie, which won several awards, was about the life of Gandhi. Your claim ought to succeed, in which case the damages will be substantial. That cannot be used instead of which in this meaning.

When

Used after an expression of time to mean “at which” or “on which”: Sunday is the only day when I can relax. There are times when I wonder why I do this job.
At which time: on which occasion: The last time I went to Scotland was in May, when the weather was beautiful.
What / which time: Until when can you stay? “I’ve got a new job. Since when?”

Where

Used after words or phrases that refer to a place or situation to mean “at, in/ to which”: It’s one of the few countries where people drive on the left.
The place or situation in which: We then moved to Paris, where we lived for six years.
(In) the place or situation in which: This is where I live. Sit where I can see you. Where people were concerned, his threshold of boredom was low. That’s where (= the point in the argument at which) you’re wrong.

Why

Used to give or talk about a reason: That’s why I left so early. I know you did it – I just want to know why. The reason why the injection needs repeating every year is that the virus changes.

That

Used as a relative pronoun to introduce a part of a sentence, which refers to the person, thing or time, you have been talking about: Where’s the letter that came yesterday? Who was it that won the US Open? The watch (that) you gave me keeps perfect time. The people (that) I spoke to were very helpful. We moved here the year (that) my mother died.
Note: In spoken and Informal written English that is nearly always left out when it is the object of the verb or is used with a preposition.