The episode begins as Data composes a letter to Commander Bruce Maddox (a cyberneticist at the Daystrom Institute, who was first introduced in "The Measure of a Man"), detailing a normal day in his life, with a focus on friendship. Since Data does not yet sleep (this happens later in the series), this episode both begins and ends with Data in command of the night shift on the Enterprise's bridge.
One of the several sub-plots is the impending wedding of Transporter Chief Miles O'Brien and civilian botanist Keiko Ishikawa, which Keiko decides to call off, telling Data in frustration that it will make her happier. Data delivers this news to Chief O'Brien, believing that since O'Brien wants to make Keiko happy, he will be pleased. He, of course, is not. Geordi assures Data that the wedding will proceed as planned.
The other important sub-plot includes a Vulcan ambassador, T'Pel, who has arranged a secret meeting with a Romulan ship. Data is assigned as her escort while she is on board. T'Pel asks Data about the Enterprise's defense capabilities, which Data finds suspicious, but after Data informs her that he has the same safeguards as the ship's computer regarding reporting such requests to Picard, she drops the question, claiming she was interested only in testing Data's safeguards. Because Vulcans do not lie, Data decides not to pursue the issue.
Data then asks Dr. Crusher to teach him how to dance, having discovered from her service record that she won dance competitions. She agrees to instruct him on the condition that he not share this information with the rest of the crew, for fear of again being called 'The Dancing Doctor.'
Chief O'Brien asks Data to persuade Keiko to go through with the wedding. He fails yet again, and talks to Counselor Troi to try to understand Keiko's decision.
In the holodeck, Data quickly learns how to tap dance from Dr. Crusher before telling her that he is ready to dance at the wedding. Telling him that tap dancing is inappopriate for social dancing she attempts to instruct him in ballroom dancing, but Data finds it much more difficult. Dr. Crusher is then called away to sickbay to deliver a baby, and Data is left alone with a holographic partner.
The Enterprise rendezvous with a Romulan warbird and, despite Picard's unease about the situation, T'Pel transports aboard. However, something interrupts the transporter signal and the ambassador is killed.
Finding no flaw in the transporter system, Data uses the principles of Sherlock Holmes to come to the conclusion that T'Pel was not really killed: The Romulans beamed her off the ship themselves and left behind genetic material designed to fool the crew into thinking that she died in a transporter accident.
Picard speeds back to intercept the Romulans in the middle of the neutral zone. He confronts the Romulan Admiral Mendak and learns that T'Pel is actually a Romulan spy. Before shots are fired, another Romulan warbird appears next to the first one and three more enter the sector, minutes away. Picard is forced to retreat into Federation space.
Data approaches Keiko to make amends. She informs him that she is not angry at him, and that the wedding will proceed as planned. Miles and Keiko are married by Captain Picard.
Data notes that although there are many emotions that he does not understand and can not share, he does understand the emotion of love and belonging.
Later, in sickbay, the captain and Data visit the newest member of the Enterprise crewâa baby born while the Enterprise was in mortal peril.