"The cat sleeps near the dog."
Translation:El gato duerme cerca del perro.
my understanding from studying spanish is that "cerca de" is the phrase "close to" "near to" and that "de" is the preposition "to" in that phrase and yes it always goes together from my recollection. far from is lejos de - in this case "de" is "from" - de is translated loosely if I remember as "to/from/of..." depending on which phrase it is in. It is part repetition for learning to just "know" but also situational - so for distance - we'd use "de". if we use "to" as in the situation give an object "to" someone - this would be using "a" not "de".
unfortunately, the prepostion "de" and "a" smoosh together with the definite article "el". - de + el = del. a + el = al. I used to think of it from an etymological perspective - that speakers smooshed the words together so many times that it became 1 word. If you say it fast a lot, you'll notice it's almost impossible to make them sound separate. :)
Hope that helps
cerca de = "near" http://spanish.about.com/od/prepositions/a/compound_prep.htm
The "contractions" of de + el = del and a + el = al are not optional, as contractions are in English. (This is el for "the" and not él for "he") http://spanish.about.com/od/prepositions/a/preposition_de.htm