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 toward the end of 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 it will make her happier. Data delivers this news to Chief O'Brien, believing that since he wants to make Keiko happy, he will want to call off the wedding. This, of course, has disastrous results. Geordi assures Data that the wedding will proceed as planned.
The other important sub-plot includes a Vulcan Ambassador, T'Pel, who had arranged a secret meeting with a Romulan ship. Data is assigned to escort her while she is on board. T'Pel asks Data about the Enterprise's defense capabilities, which Data finds suspicious, but after she is informed that Data has the same safeguards as the ship's computer regarding reporting such requests to Picard, she drops the question, claiming she was only interested in testing Data's safeguards.
Data then asks Dr. Crusher to teach him how to dance, having discovered from her service record that she had won dance competitions. She agrees to instruct him on the condition that he not share this information with the rest of the crew, not wanting to be called 'The Dancing Doctor' again.
Chief O'Brien then asks Data to convince 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, but learns that the style is inappropriate for social dancing. When she attempts to instruct him in ballroom dancing, Data is much more challenged. Dr. Crusher is then called away to sickbay to deliver a baby, and Data is left alone with a holographic partner.
The Enterprise then meets 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 the transporter beam.
Picard turns back, and intercepts 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. Picard is then forced to retreat into Federation space.
Data then approaches Keiko to make amends. She informs him that she is not angry at him, and that the wedding will proceed as usual. Miles and Keiko are married by Captain Picard.
Data notes that though 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.