Hello Yujin,
all four cases in German depend on simply three things:
- Subject (always nominative)
- verbs:
- nominative (example "sein", "werden"; Er ist der neue Direktor.)
- accusative (example "haben"; Er hat einen neuen Hut.)
- dative (example "gehören"; Das Buch gehört dem Nachbarn.)
- genitive (example "bedürfen" = brauchen; benötigen;
Das bedarf deiner Hilfe.)
- prepositions
- accusative (example "für"; Das Buch ist für dich.)
- dative (example "zu"; Er geht zu der Bank.)
- genitive (example "trotz"; Wir gehen trotz des
schlechten Wetters spazieren.)
There is also one group of prepositions which is either a. or d., depending on the question is something being put somewhere or stationary in a place.
Furthermore, in spoken German some prepositions tend to be used with dative instead of "rule-book-rules" genitive.
Lastly, there are many verbs used in conjunction with a preposition. They have to be learned seperately.