The invention discloses an association rule algorithm based on an Apriori improved algorithm. First of all, a transaction database D is preprocessed, after data records are simplified, the data records are all read into a memory, in the process when candidate sets are generated through connecting and cutting frequent item sets, the process when the candidate sets are generated is improved, a candidate item set is directly generated, the database is scanned for calculating support after the candidate sets are obtained, and since the candidate sets and the transaction database D are ordered, when the candidate sets are respectively searched for in each transaction T, i.e., each record, once values greater than a candidate item are sought, search of the transaction is stopped. According to the invention, the improved Apriori algorithm is applied to a pharmacy management system, results indicate that the performance of the improved algorithm is obviously better than a conventional algorithm, the operation is concise, and actual demands are better satisfied.