The dative case is used to show indirect objects in Latin. Indirect objects really need to be understood in English first.
Indirect objects are always used with verbs of giving, showing, and telling. They come after the verb and before the direct object and answer the questions "to whom?" or "for whom?" You can never have an indirect object without a direct object.
example: I showed the girl the example.
In this sentence, we have a verb of showing. We should expect to see an indirect object. To whom did I show the example? To the girl. The girl answers the question "to whom?" and comes after the verb, and before the direct object. This would indicate the girl is the indirect object.
Another way to show this same idea would be this example sentence.
example: I showed the example to the girl.
The prepositional phrase "to the girl" comes after a verb of showing and answers the question "to whom?" It does not come after the verb and before the direct object. In English, even though this sentence means the same as the first example, you do not have an indirect object.
In Latin, the concept of a prepositional phrase doesn't influence the use of the dative case. An indirect object in Latin can be translated into a prepositional phrase in English. Why? In English, when "to" is followed by a noun, it is always a prepositional phrase.
In Latin, the function of the word in the sentence determines what kind of ending the word has. If "to the girl" follows a verb of giving, showing, or telling and answers "to whom," it is dative. The position of a word in Latin does not effect its use or meaning in a sentence.
The dative endings for the 1st and 2nd declensions are shown in the chart below. Notice where the dative endings are placed.
The "to" problem
There are several different ways to express the word "to" in English, but each has a very specific way to be translated into Latin.
I. The police officer liked to drink coffee.
When you have "to" followed by a verb, it is called an infinitive. In Latin, there is no special word for "to." It is part of the ending of the verb (-re). The verb for "to drink" is bibire.
II. I sailed to the famous island Britain.
When you have "to" that shows some kind of motion from one place to or towards another, it is rather different than the "to" plus a verb. In Latin, when "to" expresses motion, you must use a preposition. The preposition that means "to" is ad. Its object is in the accusative case. In the example, you would translate to the famous island Britain as ad insulam claram Brittaniam.
III. The man gave a horse to the farmer.
In this sentence, "to" follows a verb of giving and answers the question "to whom?" Therefore, "to the farmer" is acting like an indirect object. Even though the same preposition is used as the sentence above, its meaning is different. In this sentence, "to the farmer" would be expressed by the dative alone. The "to" is included in the ending (just like genitive is translated by "of", but there is no separate word in Latin for "of"). In the example, to the farmer would be translated simply as agricolae.
Lastly, it may seem that you have to deal with another ending that looks similar to the others. This is true. In first year Latin, you really don't have to worry about seeing the dative very often at all. You just need to make sure that if you have a verb of giving, showing, or telling, you really keep your eyes open for a word with a dative ending. That is the best advice you can get.