Design the defining diagram, hierarchy chart and the algorithm that will determine the percentage sales commission earned on loyalty customers' purchases from a customer file.