The dative case is used to signal that we are talking about the indirect object (the noun that receives something). We also use the dative case after certain verbs and prepositions.
The questions for the dative case are "Wem?" (To whom?) and "Was?" (What?)
Who does the car belong to? – Dem Mann!
The verb "gehören" always requires the dative case.
Who does the boy give the flowers to? – Einer Freundin!
"Freundin" is the indirect object. She receives the flowers.
What does the boy give to her? – Die Blumen!
"Die Blumen" is the direct object. It is acted upon. That's why it's in the accusative case.
In the dative case, all the articles change from the nominative case!
When the plural form doesn’t end in "s" or "n," the plural form in dative requires an extra "-n" added on to the end.
In sentences with more than one object, the indirect object is always in the dative case - unless there is a preposition that requires the genitive or accusative case to be used.
The person performing the action ("er" → he → subject → nominative case) gives something ("die Schlüssel" → the keys are acted upon → direct object → accusative case) to a receiver ("dem Mann" → the man gets something → indirect object → dative case)
The noun in the dative case is usually the person who receives the thing that is in the accusative case.
After certain verbs (verbs with dative complements), the dative is always used. For example, "helfen," "gehören," "zuhören."
Those verbs require the dative case. The object is still the "direct object," but the verb can only be used with the dative case.
The prepositions "aus," "bei," "gegenüber," "mit," "nach," "seit," "von," and "zu" can only be followed by nouns in the dative case.
It doesn't matter if it's a direct or indirect object - the preposition determines the case.
Just like for the accusative case: If you have a preposition in front of a noun, none of the other rules apply anymore. It doesn’t matter if it’s a direct or indirect object, or if the verb requires a special case!
All that matters is what the preposition says!