As the daughter of an urban legend, the Last Centurion, and a fairy tale, River Song couldn't be anything but a complex literary event - of course, all of the Ponds and the Doctor become characters in the Melody Malone novel. Yet River receives a really special treatment, since I read her as woven into a dense web of literary images and symbols.
On a strictly narrative level:
Obviously, River Song is the main character in her diary, Melody Malone, the child in the AGMGTW poem, the impossible astronaut from the nursery rhyme, the woman who kills the Doctor from the legends/gossip/archaeology reports.
She is also the absolute narrator. In literary terms, she is the 'I' of the diary and the novel. Literally, she lends her voice to the narration in AGMGTW & FoTD – and we can't simply put that down to Alex Kingston’s enticing voice. Not only does she narrate her early childhood in AGMGTW but also her life & death in the FoTD epilogue, since she tells of her life from the grave – that was brilliant on Moffat's part! Few narrators can brag about that.
She is finally the writer of the book of her life - her diary - and of a mystery novel. Both books are essentially wrapped in secrets, both dangerous to read since they contain spoilers. Their puzzle must be solved differently – the diary can't be read and only time will enable the audience and the Doctor to understand a posteriori the hints. Whereas the mystery novel, if correctly written, gives all the clues necessary to solve the mystery beforehand. And her whole life from the beginning is exactly that, a mystery. Plus, note the genre, detective story of the Hardboiled School: dark and sometimes trash but which can upgrade to roman noir, thus unveiling some deeper truths about the human soul, a dive into the tortured mind. Which is exactly her diary. It is after all a diary, not a journal, not a log, but a very personal record of her life. Yet it is River Song's diary, not Melody Pond's. The name she is known under is an alias, who she fundamentally is though – her nom de plume of sort.
But in fairness she is all of that to her own life, since she is a paradox and acts to ensure she exists – she could, theoretically, undo things. She creates, lives, enacts, sometimes stages her story. And then writes it down in the diary or the novel. Being narrator, writer and character, even beyond her death, needless to say she is the ultimate autobiographer!
On a metaphorical level:
River is basically a book, as BBC!Irene Adler's whole life is a phone.
I explain myself. For a 51st century gal, she funnily keeps coming back to books and papers : she references the book on the Angels – think of it, a book, dust-smelling, hand-written, when she never leaves her pocket computer, a portable library ? – the Pandora's Box one, Amy's illustrated book, the children's testimonies for her thesis – paper again, crisp, creamy paper, not words on a screen. Given the number of times we've seen people including herself on the new show checking for information on screens and computers, it is noteworthy. Generally, only the episodes dealing with literary figures (save Tooth & Claw) display characters going through books (please, correct me if I'm wrong, my memory is a Swiss cheese). Yet in series 5, she is seen with a book in hand (other than her diary) in both her appearances. Because books are also knowledge.
The Doctor, for all his science and erudition, doesn't bring his companions to Charles Darwin or Einstein. He visits Dickens and Agatha Christie, Shakespeare and Virginia Woolf. Of course he has a grand time discussing atoms with Einstein, but we are shown he chooses to bring his companions to literary figures. Let's strech this idea and say he embodies the fictional attraction of books (save Tooth & Claw), likening River to the practical erudition, the mine of information in a book.
More accurately, the Doctor is Jules Verne : it's science, rearranged to create adventure and fictional enticement ; there's tension, there's color, there's mystery, there are scientific details for all, sometimes bold conjectures based on recent discoveries, sometimes accurate exhaustive instructions, and sometimes the-heck-we-put-those-words-together-because-it-sounds-pretty descriptions – yes, Jules Verne did that. River has a scholar approach to book. She seeks information in them, material to solve the mystery or complete her research. Naturally, she is an archaeologist, which implies a lot of reading and documenting. So a very practical approach to reading. Except in the afterlife...
(If you're still reading and don't think I'm a pompous dope, let me love you. Be brave, you're halfway through.)
Indeed, Melody Malone's book and her own thesis probably already are in the Library, when she dies and is uploaded to the data core. The Doctor also leaves her diary in the Library in the biography section, cementing her status as a book. The only physical trace she leaves behind is not a corpse, but a battered, time-worn blue diary. But River Song is a complex time event and is far more than a book – by the way, where was it in TATM?
River is, at the end of her life, an opus perfectum, she has been written – and rewritten – over and over again, perfected in the etymological sense that is finished. She is a crafted, tailor made being and her diary the definitive –even if incomplete- insight of a personality – the Doctor's -, account of a life -hers-, and of a 'love' story. The book written and closed, she remains in the Library, her mind extending within the limits of the huge core, becoming the Library, as CAL was. Her mind is indeed as well reproduced as Cal's was. As a death, River ends up giving her memory space to the computer, thus becoming part of the Library as a story and becoming the Library as much as CAL.
Going further, many analogies can be drawn between the human brain/memory and libraries (store space, shelving/gyrus, deterioration, etc.), so what I'm about to say is not far-fetched. Stop and think of it; what has been uploaded in the Library is a copy of River's mind. She died, yet a copy of herself keeps on going... Isn't that the original purpose of libraries? A place where monks endlessly copy originals and treasure the reproductions within their walls, always collecting more material for later study. The fact she dies burning is telling; many libraries were lost to fire (bring on the Name of the Rose fanatic).
So River, books, library, all the same? That would be reducing her to a passive state and her actions/functions are heavily imprinted with her last trip to the Library.
On a functional level:
As an archaeologist she puts together the pieces of the puzzle, first about herself, then about the Doctor, she creates herself, - probably more than the Bad Wolf. She is there to put back together the Doctor's remnants (I'm following this poster's footsteps), to ensure he is watched after, curated. The way she deals with his tantrums and outbursts, playing the long game, could be equated with the way a restorer patiently stiches the pieces together, even if it's always the same that fall down. But her work is about leading what might be, rather than losing herself in something that is dead. Think of it, she orders him not to travel alone; she brings him back to life in LKH.
It's the Doctor's and River's mouth interlocking in TWORS that triggers the time to get back to its original linear track. This is really interesting because, why on earth would River and the Doctor need to touch? When she kills him on the beach she does so, not only from a distance, but also separated from him by layers of materials within her suit. The touching is necessary because they need to be put back together, to complete each other, to let time flow again. Likely, it ties up to the myth of the Androgyny – the idea Man and Woman are parts of a sole being cut in two at the creation- which is all the more accurate that River has been tailor made for him (talk about Adam's rib). Except it's time itself that is made complete by their reunion. They are the stuff that time is made of. Their reunion brings forth time, again.
As a result, River's final sacrifice is all about bringing life. Indeed, it took a whole team of archaeologists to restore the 4022 prisoners of the library – releasing their imprints from their dust & digits vault to give them shape again. And those men and women of science end up as memories in books, in a realm that is quite different from any paradise, not alive but remaining at the core of knowledge itself, with the imprint they left on their field of work to keep them alive on the living men's lips. And River ends up with three children. Which turns her into a teacher, a nurturer, but that's another discussion.
River is very much the librarian, as well as the archaeologist. She provides people with the books they need – first the definitive work on the Angels, the key to understand the Doctor has been trapped i.e. Pandora's Box, her blank diary to trigger Amy's memory, the Melody Malone book in a timey-wimey way. Note the Doctor insists on the fact that she wrote it, as if it is her fault, when Amy typed it. She is the one who brings up the appropriate material for the adventures.
Her diary can be seen as a magnificently blue bookmark into the Doctor's life, her parents' and hers, to keep track of time like those slices of paper dated with the previous loans. The coordinates she left on the oldest cliff face in the universe may resemble the huge letters on shelving, a guidance to find one's way. Funnily, her words 'Hello Sweetie' and 'Bye' in Stormcage are written in stone, thus creating material not only for future archaeologists but also for the Doctor, unwillingly turned into an archaeologist by her scheme and launched on a hunt for Cleopatra.
Finally, River is the ultimate Doctor's storyteller, because he saves her, therefore ensuring that his story lives on forever through hers –although I'm quite sure a computer's memory or at least its material deteriorates with time.
Which brings me to another aspect of her storyteller status. The nature of the story she tells changes after her death; it becomes a tale. Her life with and without the Doctor as told to CAL and Donna's children has become a tale, a legend ; like the Pandorica, a fairy tale turned into reality by the imagination of a young Amy, like Demon's Run, like the Doctor's death before. Because what River calls archaeology is idle gossip to the Doctor; indeed he has time, he has perspective. He is aware no matter how hard humans try to record History, who knows the figments that will reach our descendants in 2000 years. A little part of what we call History is actually conjectures and suppositions, half legends half speculations, experts recognise it. Of course, scientific and historians are working hard to fill up the holes, erase the inconsistencies and we have a pretty good idea of what happened before. Yet we don't know how Kheops pyramid was built or what was the matter with the Trojan War.
The Doctor's story – and River's- belongs to that part of History, legendary and historically controversial. That's why River reads a bedtime story that is essentially her life. I'm going to go a little further and venture to say that's why she breaks the fourth wall and has a Midsummer Night's Dream Puck moment at the end of the episode: she acknowledges her life as passing into legend, reaching the land of stories rather than History, since as part of the Doctor's life, she must remain secret, whispered, not scrutinized. Because 'that's a fairy tale.'
'Aren't we all?'
How fitting it is for her to die in the Library and turn into a story.