Fixed auto-increment and primary key issues with SQL