We propose a new algorithm called SCD for learning the structure of a Bayesian network. The algorithm is a kind of constraintbased algorithm. By taking advantage of variable ordering, it only requires polynomial time conditional independence tests and learns the exact structure theoretically. A variant which adopts the Bayesian Dirichlet scoring function is also presented for practical purposes. The performance of the algorithms are analyzed in several aspects and compared with other existing algorithms. In addition, we define a new evaluation metric named EP power which measures the proportion of errors caused by previously made mistakes in the learning sequence, and use the metric for verifying the robustness of the proposed algorithms.