This is called a Hi / Lo assignment.
You would do this with the INSERT trigger in your tables, getting the identifier from this table and incrementing it before or after getting your identifier, depending on your choice.
This is commonly used when you have to deal with several database engines. An auto-incrementing identifier in Oracle is a SEQUENCE that you increment with SEQUENCE.NEXTVALUE due to a BEFORE INSERT TRIGGER in your data table.
In contrast, SQL Server has IDENTITY columns, auto-incrementing initially, and this is managed by the DBE itself.
For your software to work on both DBEs, you must come to some standard, then the most common “standard” used for this is to assign Hi / Lo to the primary key.
This is one approach among others. Nowadays, using ORM Mapping tools such as NHibernate is offered through configuration, so you need to worry less about both the application and the database side.
EDIT NO. 1
Since this kind of maneuver cannot be used for a global area, you will have to have such a table for each database or database schema. Thus, each circuit is independent of the other. However, data in one schema cannot implicitly move to another with the same key, because, perhaps, this would contradict an existing line.
As for the security scheme, it accesses the same database as another scheme or user, so there is no additional table for a specific security scheme.
Will marcouiller
source share