River Song first appears in the Doctor Who 2008 series two-parter "Silence in the Library"/"Forest of the Dead" (written by Steven Moffat) in the Russell T Davies era of Doctor Who. Here, she encounters the Tenth Doctor (David Tennant) in the 51st century, and claims to be someone he will come to trust completely. River, who wears a space suit, carries a TARDIS-colour/pattern diary of her adventures, and is a professor of archaeology, is able to convince the Doctor of his future trust in her by whispering his real name into his ear. The adventure in the Library is River's last encounter with the Doctor in her chronology, but is their first encounter in his. In the second of the two episodes she sacrifices herself to save the people who were trapped in the Library's database, before the Doctor could do the same. In turn he is able to upload her consciousness into a computer, in which she is able to live on in a virtual world created by the Library computer. He achieves this via the use of a sonic screwdriver given to her by his own future self.
After Moffat took over from Davies as executive producer of the show, River Song appeared in the 2010 series. In the two-parter "The Time of Angels"/"Flesh and Stone", which takes place prior to River becoming a professor, she encounters the Eleventh Doctor (Matt Smith), with whom she is more familiar. She leaves coordinates for the Doctor so that he may rescue her in the 51st century, and together they investigate the crash of the spaceship Byzantium. She shows herself to be more adept at flying the TARDIS than he is and reveals to the Doctor that she is imprisoned in the "Stormcage Containment Facility" for killing, "the best man I've ever known." An even earlier version of River appears to assist the Doctor in series finale "The Pandorica Opens"/"The Big Bang". After being contacted by Winston Churchill (Ian McNeice), River leads the Doctor to 102 A.D. While River is travelling in the TARDIS on her own, it explodes with her inside. The Doctor, using River's vortex manipulator, teleports her out. River then assists him in closing the cracks in the universe. After the Doctor erases himself from history in order to completely close the cracks in the universe, River helps Amy Pond (Karen Gillan) to remember the Doctor and bring him back, by giving Amy her now-blank diary. At the close of the series finale, River ambiguously suggests to the Doctor that she is married and tells him that he will soon learn the truth about her, after which 'everything changes'.
In 2011 series opener "The Impossible Astronaut"/"Day of the Moon", River, along with Amy and her husband Rory (Arthur Darvill), is contacted by a future version of the Doctor to convene in the United States. This Doctor is killed by an assailant in a space suit, and the trio give him a Viking funeral. In 1969, the present Doctor and company subsequently encounter a little girl (Sydney Wade) who wears the space suit, which River tells the Doctor is a life support unit; the suit has been designed by the hypnotic alien Silence. Homeless, the girl is later shown regenerating in New York City, 1970. In "A Good Man Goes to War," it is revealed that River is Amy and Rory's daughter Melody, who was conceived in the TARDIS and consequently carries Time Lord DNA. Baby Melody is kidnapped by Madame Kovarian (Frances Barber) to become a weapon against the Doctor. "Let's Kill Hitler" establishes that Melody was trained by the Silence to kill the Doctor. After regenerating in New York, Melody became Rory and Amy's childhood friend Mels (Maya Glace-Green) and grew up alongside them. When adult Mels (Nina Toussaint-White) is shot, she regenerates into her next incarnation (Kingston) and proceeds to assassinate the Doctor. Persuaded she will one day become River Song, in whom the Doctor places great trust, Melody chooses to resurrect the Doctor with her regenerative energy, losing the ability. The Doctor learns, however, that it is she who kills him in his future. The Doctor gives her a blank TARDIS-shaped diary, and Melody—now River—enrolls to study archaeology. At the end of "Closing Time", on the day she receives her doctorate, the Silence and Kovarian recapture River and place her in the space suit to kill the Doctor as history records. In series finale "The Wedding of River Song", River resists killing the Doctor, creating an alternate reality. The Doctor marries River and convinces her to return to the established course of events by letting her know how he plans to fake his death; River goes to prison for his murder to corroborate the deception.
River appears again in the fifth episode of the seventh series titled "The Angels Take Manhattan". Amy and the Doctor meet River in 1930's New York whilst trying to find Rory who has been sent back in time by the Weeping Angels; a book written by River under the pen name Melody Malone helps them find him. Exposition reveals that River, now a Professor of Archaeology, has been pardoned for the Doctor's murder; as he had erased himself from every known database in the universe. Although the angels are defeated a lone survivor manages to send Rory back in time where he is destined to live out his natural life before dying. River encourages Amy to allow herself to be taken by the Angel, in the hope that she can spend the remainder of her days with Rory. The pair share an emotional farewell, in which Amy tells River to look after the Doctor, and not to let him travel alone. Following Amy's farewell River pledges to travel with the Doctor, but not on a permanent basis.