I'd say like that because the teacher who has taught us grammar like that and there are some rules
I saw a girl whose name was Maryam.
1- this relative pronoun and use it with possessive.
2- whom vs whose. Whom is not very common in spoken English and use it to replace object, for example, this is the police officer. I spoke to him. Answer, This is the police officer to whom I spoke. Thank you for your question that helps me to remember what I've learnt.