Quick answer
Кото́рый takes its gender and number from the noun it refers back to, and its case from its own clause. A comma always comes before it.
Two rules, two sources
Gender from the noun before the comma; case from the job it does after it. Once you separate those two questions, the form is easy.
The comma is obligatory
English can drop “that”; Russian can never drop кото́рый or its comma. Кни́га, кото́рую я чита́ю — never “книга я читаю”.
The one to learn first
The nominative forms cover most of what you will say early on: кото́рый, кото́рая, кото́рое, кото́рые. Add the accusative кото́рую and you can describe almost anything.
Typical mistakes
Кни́га кото́рую я чита́ю
Кни́га, кото́рую я чита́ю
The comma is compulsory.
Э́то кни́га, кото́рый я чита́ю.
кото́рую
Feminine noun, accusative role.
Check yourself
Э́то кни́га, ___ я чита́ю.