According to the author of Luke, Joseph came to Bethlehem "because he was of the house and family of David, in order to register, along with Mary, who was engaged to him, and was with child" (Luke 2:4-5). Does this verse show that Mary was a descendant of David?
There is nothing in these verses to show that Joseph and Mary were both of Davidic ancestry and, therefore, going to the same town to register. As his future spouse, one might stretch credulity to the maximum and presume that Mary, in an advanced stage of pregnancy, accompanied Joseph on the journey, but are we to believe that she went to Bethlehem because she too had to register as a descendant of David? This would suggest that married and unmarried women, not fortunate enough to have a spouse or fiancé traveling in the same direction, were out on the road with no one to protect them.
Credulity is stretched to the limit by the intimation that young and old, the healthy and the invalid, married and unmarried took part in this mass movement of population and the historical records remain silent about its occurrence.
The author of Luke utilized the historic fact that the Romans took a census about a decade after the birth of Jesus. He then connected this census to the time of the birth of Jesus and exaggerated its registration requirements in order to have Mary accompany Joseph to Bethlehem. Luke emphasizes what he believes to be Joseph ancestry, not Mary's.