In a game server code in Java, I split the client data into many tables, to ease adding new content in the future.
Right now I have the following tables
- names
- auth
- inventory
The name table contains the columns id and name.
The auth table has columns id and password.
The id column on the auth and inventory tables have foreign key constraints on the name's id column.
When creating a new client, I insert into the name table, get the generated id and insert the rest of the data in the other tables in separate insert statements, but all in a single transaction.
The problem is, when I insert into the auth table, it fails because of the foreign key check in name because I haven't commited it yet. Is there a better way to solve this without commiting on every insert?