Because I'm so nice I'm going to explain was DEM is!
DEM is used instead of DER or DAS when those words are standing as DATIVE objects. There three different situations when you use this:
*After certain prepositions: There are prepositions that controls DATIVE and there are those controlling DATIVE but also ACCUSATIVE and GENITIVE. I'm not going to cover them all here but I'm going to go through when which is used.
Ich laufe nach dem Hund - I'm walking behind the dog (the dog - der Hund)
Here NACH is a preposition that controls DATIVE. This is the easy part. When this preposition exists, you just chance DER and DAS to DEM (DIE becomes DER in singular).
The other set of prepositions controls DATIVE when something doesn't move as oppose to when something move it controls ACCUSATIVE.
Ich gehe in den Wald - I'm going to the forest (ACCUSATIVE - movement)
Ich bin in DEM Wald - I am in the forest (DATIVE - no movement)
Most prepositiones are contracted with the article so more correct would be "Ich bin im Wald" but that's another story.
*When you are doing something for someone: If you give someone something or if you are telling someone something, then you use DATIVE.
Ich erzähle DEM Kind ein Märchen - I'm telling THE child a story
Ich gebe DEM Hund etwas zu essen - I'm giving THE dog something to eat
*The worst part, situations with no logic! You just have to learn which expression uses which cases. Hmm, an example could be "Ich glaube dem Kind - I believe the child" if you don't think that the believing is something you do for the child. There are tons of more unlogical expressions but I can't think of something now.
I hope this helps a little at least
