A commercial for an Icelandic phone company from a few years ago depicted a couple waking up after a one-night stand. They both pick up their smart phones. They both log into a family-tree website, Islendingabok. And that’s where things get awkward.

There are only 320,000 people who live in Iceland, and most are descended from a small clan of Celtic and Viking settlers. Thus, many Icelanders are distant (or close) relatives. Sometimes too close.

The desire to avoid unwitting incestuous pairings at one point even spawned an app, created by a group of engineering students at the University of Iceland, that allows its users to bump their phones together to determine whether they share a common ancestor. (Tag line: “Bump in the app before you bump in bed.")

Johan Peter Raadsig/Wikimedia Commons

Concerns about wading into the shallow end of the gene pool are just a small part of the Icelandic obsession with genealogy. As Iva Skoch explained in Global Post, when two Icelanders meet, the first question is usually, "Hverra manna ert bu?" (Who are your people?) Bookstores are stocked with thick volumes on the histories of Icelandic families.

For nearly a millennium, careful genealogical records had been kept in the Islendingabok, or “Book of Icelanders.” In 1997, Icelandic neurologist Kári Stefánsson created a web-based version of Islendingabok in order to offer his countrymen 24/7 access to their family trees. Along with developer Fridrik Skulason, he scoured census data, church records, and family archives in order to encompass what he claims is 95 percent of Icelanders who have lived within the past three centuries. It has since become one of the most popular sites in the country.

Olga Khazan/The Atlantic

“If you take the old Icelandic sagas, they all begin with page after page of genealogy,” Stefánsson told me. “It assures that the common man won't be forgotten.”

For Stefánsson, the national preoccupation with heredity has yielded an unexpected professional benefit: “Having the genealogy of the entire nation is one of the things that has turned us into the world champions of human genetics.”

Because Icelanders do such a good job of tracing their family histories, Stefánsson and his colleagues at Decode, the genetics firm he founded, have a rich trove of data for experiments. So far, he’s discovered how specific genetic mutations affect a person's chances of having everything from Alzheimer’s to blond hair. He’s identified a certain cancer-causing mutation that’s much more common in Iceland than in America, and he's uncovered a genetic component to longevity. Most recently, he and many co-authors found that a certain mutation introduced in Iceland in the 15th century is the primary driver of Icelanders’ risk of hypertrophic cardiomyopathy, a disease in which the heart muscles thicken.

Olga Khazan/The Atlantic

“Having the genealogy gives us an opportunity to figure out how everyone is related to everyone else,” he said. “If you are tracing genes to figure out disease, it is important to figure out, how does this mutation travel from one generation to the next?”

Not everyone thinks the ancestry archive is harmless. In 1998, a journalist with Der Spiegel interviewed Stefánsson and wrote that a similar genetic database in Germany would spark rioting in the streets. But Germany, Stefánsson argues, is an unusually privacy-loving nation. Icelanders have no such qualms.

“The Germans used genealogy to exterminate a population,” he said. “But we have always loved genealogy as part of our culture. We are a strange people living on a little island. ”

Olga Khazan/The Atlantic

The anti-incest bumping app was created as part of a contest Stefánsson held in order to generate mobile-friendly versions of the online Islendingabok. But Stefánsson rejects the notion that Icelanders are overly concerned with inbreeding. All the chatter about accidental kissing frændis (cousins), he says, is just that. Most people already know who their first cousins are, after all.

Instead, he touts the more serendipitous benefits of the genetic database.

“It is often that people think they might be related, and they go on the Internet and they figure out exactly what this relationship is,” he said. Once, for example, he decided to look up a grandfather who was born in 1829 and bore 2,400 descendants. It turned out, several of his co-workers and acquaintances were distant relations.

Another time, he was perusing a book about his ancestry when he saw a picture of his great-grandfather.

“He just looks exactly like me,” he said. “Now I look like this old man with this big beard.”