German is pretty rough in this respect, but it all boils down to some rules that you just have to learn.
There's a couple of levels of stuff going on.
- 1st is the gender (like a bunch of other languages, except German has neuter too for 4 total - m/f/n/pl)
- 2nd is the case (there are also 4 of these - which show the role of things within a sentence)
This gives a nice summary of the various 'thes' that you end up with when combining these two;
https://en.wikipedia.org/wiki/German_grammar#/media/File:German_die_der_das_declensions.svgYou have the same for 'a' as well.
It gets more complicated still, because the adjectives and nouns (endings) also change depending on how many you have and what role they take up in the sentence. Also certain verbs determine certain cases based on motion etc (just have to learn this).
So some concrete examples;
CASE 1 - NOMINATIVE aka is the subject (does the action)The woman is feminine, so is 'die'.
The woman (
Die Frau)
The women is plural, so is also 'die' but plural nouns tend to end 'en'
The woman (
Die Frauen)
The woman is drinking (
Die Frau trinkt)
CASE 2 - ACCUSATIVE aka is the direct object (has action done to)The dog chased the woman (
Der Hund verfolgte die Frau) the woman is accusative, the dog is nominative. If the woman chased the dog, the roles would be reversed and it'd be
Die Frau verfolgte den Hund (i.e. the dog is now accusative, the woman nominative). This technically allows you to change the order of objects in a sentence, because the case change makes it obvious what is doing what to whom, whereas in English the order is what determines this.
CASE 3 - DATIVE aka is the indirect object (indirectly does an action or has one done to them)The woman gives a bone to the dog (
Die Frau gibt dem Hund einen Knochen). Now the woman is nominative, the bone is accusative (with the accusative version of 'a' for a masculine noun) and the dog is dative.
CASE 4 - GENETIVE aka has possessionThe woman gives the boy's bone to the dog (
Die Frau gibt dem Hund den Knochen des Jungen) Now the woman is nominative, the bone is accusative, the boy is genetive and the dog is dative.
As you can see, it's quite complicated (and I've probably made mistakes), but that's the gist of it.