Fixing sql tables