Exploiting Database Management Systems and Treewidth for Counting