I am currently doing a research and would like to know what methods or algorithms are currently present to manage multi-user data insertion into two relational table (Related through Primary Key and Foreign Key).
In the primary key table,
- Primary key can either be auto-increment id or non auto-increment id.
In the foreign key table
- Every time a new record is inserted into primary key table, 2 records have to be inserted into foreign key and pointing to the primary keys of new record
Currently i am doing it like this.
1. I have 2 table (Primary Key Table with Non-Increment) (Foreign key table)
2. I have another table (counter) storing the largest primary key value
3. Every time a user insert a new record, it will read the largest primary key value + 1
4. It will then begin transaction and use commit statement to insert three records into the primary key table and foreign key table respectively
My concern is what are the alternatives available in the market?