I'm learning the grammar of relative pronouns; I thought all relative pronouns should be at the start of a clause, and then I learned that pronouns can be put after a preposition, as in "The bed on which I was lying...", but again, I came across some other examples that showed that we can put more words before the relative pronoun, as in "The bed, the owner of which we had seen previously, ...", or "The bed, lying on which was a small cat, ..."
Does anyone know what are the rules? Can we put the relative pronoun anywhere in a clause? What about these sentences: "The bed, we had seen the owner of which previously, ..."?, are they grammatically correct?