I think this sentence is the result of spaced repetition. You can write someone a book, but it is more common to write someone a letter or an email.
Here's an excerpt from a review of Sibilla Aleramo's book Una Donna (A Woman)
- ... Like Aleramo herself, the protagonist of A Woman is an autodidact who uses education to turn herself into a writer and thereby liberate herself from her marriage. But she does so at high cost: she has to leave her son behind. ... cut off from her son, she writes him a book.
It may not be a real-life sentence but it's grammatically correct. And grammar is an abstract thing, is it not? This is a good example of how an example sentence focuses on the relationships between words in a sentence, rather than the more concrete objects and actions these words might represent.
If all Duo's examples were in the vernacular as you seem to suggest they should be, we wouldn't be able to deal with them.
Most of Duo's material is quotes from a variety of sources. By necessity, for any student at this level, it is restricted in its use of tense, vocabulary, grammar and meaning.
However, in this case it doesn't take too much imagination to believe that somewhere at this very moment, a female is writing a book with a male person as the intended target.
You are arguing that the pronoun "ihm" is correct because it is the object of the sentence and therefore takes the accusative case. But "ihn" is the accusative and "ihm" is the dative! No, the answer is more complex because in German it depends on what kind of object.
The reason this takes the dative case "ihm" is because in the sentence "She writes him a book", "him" is the INDIRECT OBJECT and this takes the dative case.
In general, if a verb can take two objects, one is accusative and one is dative. A few select German verbs like fragen, lehren, and kosten take two accusative objects, but they are exceptions to the rule. There aren't many others like them, so you just have to memorize them.
Similarly, if a reflexive verb, e.g. sich erkälten (to catch a cold) takes an object (other than sich), the sich becomes dative: Du hast dich erkältet. Du hast dir die Blase erkältet. (You caught a cold. You got a chill in your bladder.)
The indirect object is always "Dative case", but there are also some verbs that require Dative. Many prepositions require Dative, but some require Accusative and a few require Genitive. There are some prepositions that can be used with Dative or Accusative for different meanings.
Sentences are not dative, each noun or pronoun is either in Nominative, Accusative, Dative or Genitive case. The subject and the predicate nominative which comes after the verb "to be" or "sein" in German are in Nominative case.
The subject "Sie" is in Nominative case. The direct object "book" in this sentence is in Accusative case and the indirect object "ihm" is in Dative case. Scroll up for some links that are really helpful to learn German cases and when to use the Dative case.
Usually the dative noun (or pronoun or noun phrase) comes before the accusative one. It's not technically wrong to change that order (because the grammar of the cases normally gives the receiver enough information to understand which is which), but it sounds really weird, so try to avoid it.
However, if one of them is a pronoun then it always comes before the other one if it is a noun. Here is a great link that helps with German word order: http://www.dartmouth.edu/~deutsch/Grammatik/WordOrder/MainClauses.html
Fun fact: "Sie schreibt die Geschichte in ein Buch" would mean writing in a physical, printed book (or perhaps making journal/diary entries), while "Sie schreibt die Geschichte in einem Buch" would refer to authoring the content of the book itself. In English, there's no such distinction; either of these sentences could be translated as "She's writing the story in a book."
Right! Although normally in the case of "in einem Buch", you would also have some kind of direct object, like "die Geschichte", or prepositional object, e.g. "Ich schreibe in einem Book über das Thema" // I'm writing (in) a book about the subject. <-- [I put "in" in parentheses because the sentence works with or without it.] If you just want to say you're writing a book (without describing what's in it), you don't use "in" at all: "Ich schreibe ein Buch".
Not always, but more importantly if one of them is a pronoun and the other a noun, the pronoun always comes first. http://www.dartmouth.edu/~deutsch/Grammatik/WordOrder/MainClauses.html
This also translates as she writes a book for him, right?
Now obviously this can mean that she is writing a book that she intends to give him. But in English we can also say she is writing a book for him meaning that she is writing the book on his behalf (because, he is disable, or he is illiterate, or he is dead and she is writing his reminiscences down as a memoir).
Is sie schreibt ihm ein Buch the correct way to say that she is writing a book for him in this latter sense?
"She writes a book for him" is most certainly a correct translation of the most common meaning of "Sie schreibt ihm ein Buch". Without any other context, most people would assume that is the meaning of the German sentence. I think the German sentence could also be translated as "She writes a book to him", but I'm not totally sure. Even if it can be translated that way, that meaning would be less common than the other and wouldn't work without context.