I think it is a logical and correct solution and I have to redesign the table.
My goal was to solve the problem without pain and bleeding!!
Exactly. Regardless of where the existing data record is located in the table, your programme can then react flexibly. How you then display this is of course up to you. Depending on the size of the database, it makes perfect sense to display this data in the form of a B4XTable (you can do without the ID...
). Or you can develop your own form for displaying the data. The user of your programme would then, for example, only have to search for the product code via the search field of the B4XTable; if this already exists, the data record is simply updated or, if not available, newly created. SQL then performs these queries very quickly in the background. For sure, I personally would keep the incremental ID of a single record. It's a "passport" for a single database record. If there are gaps in between, who cares?
I am absolutely sure you will find suitable ways. If not, please get in touch! Keep it simply und comfortable for the user. Use click functions within the B4XTable to select a record and for editing. Most of it, can be done without typing text (increment or decrement the amount on stock and so on). Sure, if a new product has to be entered, the user needs to type the name in. So it will create user satisfaction. The user needs the feeling, that he needs your comfortable programming solution, asking himself how to live without before.
And the possibilities are great. You can give the user the functions he needs (supporting counting whats on stock and what has to be ordered and so on). You can create warnings, if there is some item low on stock. Simply another value within the table to read out (minimum stock). Just my ideas.
Believe it is very satisfying for you, when the customer loves your product. And this value, he gives back to you then. If you are able to react flexible to the needs of the customer, adding by time more and more suitable functions for the customer, the customer will be happy. So it is very important to have a good concept.
Additionally, keep in mind that in future your database must be extendend. So a version check is very important if the structure of the database will change in future. Honestly said, I am not the great SQL-developer. I do most of that by using DBUtils. DBUtils will support you as a programmer in accessing the database with very good and prooved routines for accessing. Maybe it needs some milliseconds more during run. Who cares? But you don't have to think about accessing the database itself. There are also some routines built in for version checking. Just an idea...