Nowadays, automatic scoring is an important way of teaching and examinations. However, there is no existing research on automatic scoring for subjective item of database domain both at home and abroad. According to the characteristics of database domain, we construct database domain synonyms ontology and proposed a text similarity calculation algorithm based on Hamming distance. Then we implement the automatic scoring for subjective item of database domain on the basis of ontology. In addition, in order to verify the accuracy and rationality of the algorithm, we take a specific subject as an example. The experiment results further illustrate the accuracy and efficiency of the proposed automatic scoring algorithm.