fix the sql structure