Next: , Previous: , Up: Auto-Generated Fields   [Contents][Index]


12.2 Unique Identifiers

Universally Unique Identifiers, often abbreviated as UUIDs, can also be auto-generated using recutils. Suppose you maintain a database with events featuring the following record descriptor:

%rec: Event
%key: Id
%mandatory: Title Date

What would be appropriate to identify each event? We could use an integer and declare it as auto-generated. After adding two events the database would look like this:

%rec: Event
%key: Id
%mandatory: Title Date

Id: 0
Title: Team meeting
Date: 12-08-2013

Id: 1
Title: Dave's birthday
Date: 20-12-2013

However, suppose that we want to share our events with other people, i.e. to send them event records and to incorporate their records into our own database. In this case the Ids would collide. A good solution is to use uuids and declare them as auto:

%rec: Event
%key: Id
%type: Id uuid
%mandatory: Title Date

Id: f81d4fae-7dec-11d0-a765-00a0c91e6bf6
Title: Team meeting
Date: 12-08-2013

Id: f81d4fae-dc18-11d0-a765-a01328400a0c
Title: Dave's birthday
Date: 20-12-2013