How Danish surnames began
Danish surnames are dominated by patronymics ending in "-sen": Jensen, Nielsen, Hansen, Pedersen and Andersen are carried by a large share of the population. These became fixed after a law of 1828 told families to keep one surname rather than changing it each generation.
Because so few names were shared by so many people, Danish law has encouraged families since 1904 to take more distinctive names, often from places or nature.
How the names work
Danish "-sen" names correspond to Swedish "-son" and Norwegian "-sen" names, and the same name can appear in all three countries. Many Danes have a middle name that is a second family name, often from a place, which is used to distinguish them from others with the same "-sen" surname. Danish law lets people take a new surname relatively easily, and many do.