Generating Unique Values: Examples

Previous Next

See Also

Example 1:

DOM_SEQUENCE is an integer domain with 'generate unique value' flag set, and DOM_STRING a string domain.

TAB1(PK, COL) is a table with column PK defined on DOM_SEQUENCE with Key 1, and COL defined on DOM_STRING with Key NULL.

TAB2(PK, COL) is the same table as TAB1, but COL is also a Key 1

Then:

· For TAB1, USoft will create a Sequence Object for PK : when inserting a new record for TAB1, USoft will ask the Sequence Object to give a value for PK.

 

· For TAB2, when inserting a new record, the user must fill in a value for COL, then the Rules Engine will fill in PK so that (PK,COL) stays unique (the Rules Engine will query for the maximum value of PK where COL is equal to the value filled for the new record, and assign this maximum + 1 to PK of this new record).

Example 2:

DOM_SEQUENCE_BIS is another integer domain with 'generate unique flag' set.

TAB3(PK1, PK2, COL) with PK1 is defined on DOM_SEQUENCE with Key 1, PK2 defined on DOM_SEQUENCE_BIS with Key2, COL defined on DOM_STRING with Key NULL.

TAB4(PK1, PK2, COL) with PK1 is defined on DOM_SEQUENCE with Key 1, PK2 defined on DOM_SEQUENCE with Key2, COL defined on DOM_STRING with Key NULL.

TAB5(PK1, PK2, COL) with PK1 is defined on DOM_SEQUENCE with Key 1, PK2 defined on DOM_SEQUENCE_BIS with Key2, COL defined on DOM_STRING with Key2

Then:

· TAB3 will create errors : USoft cannot create 2 sequence objects for PK1 and PK2

 

· TAB4 will work : USoft will create a unique Sequence Number for both PK1 and PK2 (PK1 and PK2 will get different values)

 

· TAB5 will work : USoft will create a Sequence Object for PK1, and the Rules Engine will generate value for PK2 so that (PK2, COL) stays unique.