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.
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".
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?