Using "That" or "Which" in German (Genders)

Hello. I have been studying German for a month or so now, and I’ve been having trouble using the words that or which. For example if I wanted to say “The man that I saw” or “The woman which was there” I would say “Der Mann den ich sah” or “Die Frau die ich sah.” (Dunno if that is 100% correct). So, obviously it changes depending on the noun (Mann and Frau), however I have found some sentences that don’t appear to work this way. For example using “der” where I thought “den” should be.
I can’t seem to wrap my head around this and would appreciate it if someone could help out. Thanks.

Check these out!

Search his videos for “relative pronouns” to find more.

Thank you so much. This cleared things up a lot.

Sure thing! I also suggest browsing that Youtube channel for other grammar points. Everything is laid out clearly and it really helped me when I first got started with German. Great content.