The U.S. is a transient society where people often relocate during the coures of their careers, which often brings up a question: Which one of these places will be best for my family?

WalletHub has taken a deep dive into this common dilemma with a study that assesses how each state ranks in terms of providing a good place to raise a family.

The study took in a wide variety of factors—about 49 metrics, in fact, divided among five categories: family fun, health and safety, education and child care, affordability and socioeconomics.

The family fun category, for example, considered the share of families with young children, each state's family attractions and fitness and recreational centers, and the share of children under 17 years old who live in neighborhoods with parks or playgrounds. The socioeconomic category, meanwhile, looked at data such as separation and divorce rates, poverty and unemployment rates, and the percentage of two-parent families in each state.

The affordability category went beyond just prices, including metrics such as credit scores, mortgage debt, college savings rates and the availability of paid family leave.

The ranking could be used as a guide for families facing a relocation, but WalletHub noted that with so many factors to consider, families will inevitably have to make some compromises. "Wants and needs don’t always align in a particular state," the report stated. "For instance, a state might offer a low income-tax rate but have a subpar education system. However, families do not need to make these kinds of tradeoffs."

Still, some states faired poorly no matter how you looked at the metrics. New Mexico achieved the inglorious distinction of finishing in last place on the list. The state was among the worst five states in the nation when it came to median family salaries, poverty rate, violent crime rate and divorce rate. Finishing just above New Mexico in the bottom five were, in ascending order, Mississippi, Lousiana, West Virginia and Alabama.

The following states, in ascending order, topped WalletHub's ranking for best places to raise a family:

10. Nebraska

The state finished ninth in the socioeconomic category, while it was also among the top 12 in health and safety, and in education and child care. Nebraska also ranks second in the nation for affordable housing and has the fourth-highest percentage of families with young children.