Base: How to create 'universal unique' ID for record transfer

When transferring records between BD users, what do you use to prevent confusion between records with the same ID?

1 Like

Just for my curiosity: What is a “BD user”?

There must either be an authority managing such identifiers (which we only have for special purposes), or an identifier (add-to most likely) must be generated randomly targeting into a sufficiently large space with a reliable algorithm to get uique values with sufficiently high probability without additional measures.
A standard seems to be to use 128-bit values, which can distinguish more tha 10^38 values.
(About 2 000 000 000 000 000 000 000 000 000 000 per currently living human).
Where restricions are neecessary, they must be negotiated.
Just one finding on the subject e.g.: Generating UUIDs at scale on the Web | by Matthieu Wipliez | Teads Engineering | Medium

I’ve skimmed the article; interesting. However, specifically how are people getting a UUID or GUID into an LO Base field?

I’m coming from a Filemaker background where you’d auto-enter UUID into 1 field of each record of each table. It needs to have a similar mechanism to be practicable.

1 Like

Hello,

This is not available in Base but many newer databases (HSQLDB v1.8 embedded is not one) provide a function:

HSQLDB (v2.x & up)

image description

Firebird -

image description

MySQL -

image description

and PostgreSQL documentation:

PostgreSQL provides storage and
comparison functions for UUIDs, but
the core database does not include any
function for generating UUIDs, because
no single algorithm is well suited for
every application. The uuid-ossp
module provides functions that
implement several standard algorithms.
The pgcrypto module also provides a
generation function for random UUIDs.
Alternatively, UUIDs could be
generated by client applications or
other libraries invoked through a
server-side function.

This is limit of checking done. It is likely other DB’s as similar.

1 Like

Another option to create a universally unique identifier (UUID) is this formula

=CONCATENATE(
DEC2HEX(RANDBETWEEN(0;4294967296);8);"-";
DEC2HEX(RANDBETWEEN(0;65536);4);"-";
DEC2HEX(RANDBETWEEN(0;65536);4);"-4";
DEC2HEX(RANDBETWEEN(0;4096);3);"-";
DEC2HEX(RANDBETWEEN(0;4294967296);8);
DEC2HEX(RANDBETWEEN(0;65536);4))

Example of random end result 8D8AC610-566D-4EF0-9C22-186B2A5ED793


Below is the answer as above. But with details for those interested.

Assumptions about the formula above:

If your Calc is in another local (language), you need to adapt this formula appropriately.

For example, in French the correct formula is this:

=CONCATENER(
DECHEX(ALEA.ENTRE.BORNES(0;4294967296);8);"-";
DECHEX(ALEA.ENTRE.BORNES(0;65536);4);"-";
DECHEX(ALEA.ENTRE.BORNES(0;65536);4);"-4";
DECHEX(ALEA.ENTRE.BORNES(0;4096);3);"-";
DECHEX(ALEA.ENTRE.BORNES(0;4294967296);8);
DECHEX(ALEA.ENTRE.BORNES(0;65536);4))

For creating a new UUID, simply exit the cell edit mode, while you view the cell, press F7 key, this will automatically calculate a new UUID.

Attribution to Matt for the inspiration about this formula. Which I adapted for both UUID version 4 format and the maximum amount of Hex values. Which I assume is 16^8 = 4294967296, 16^4 = 65536, 16^3 = 4096.

Note that semicolon is accepted in all locales, even those that use other separators in the UI (so they will accept the formula with semicolons, and then show the separators as configured locally). Which is why it is advised to always use semicolons as separators when pasting formulas to sites, to minimize problems for users. If only there existed a similarly universally accepted format for other parts (like decimal separator or function names)…

1 Like

Thanks for your reply @mikekaganski :slight_smile: I learned something new. I adapted my answer accordingly.

This is good news that semicolons are universally accepted. I prefer formulas with semicolons. As they are easier to read.