[erlang-questions] Mnesia and automatic generation of primary keys

Matej Kosik <>
Mon Jul 2 12:33:42 CEST 2007


The best tutorial to using Mnesia I have found is this document:

According to that information I was able to set up a database, add tables, entries and make some querries. Ok.

Now when I am thinking about tables I need and their attributes, I would like to generate unique primary keys for new entries to certain tables (where none of their attributes is a clear candidate for primary key).

Is there a lucid way to generate such primary keys (that will guarantee uniqueness of those keys during the whole lifetime of that table) regardless of how many times the system will be shut down and restarted. Do you also have this problem? How do you solve it?

Should I set up some kind of global table where I can use "last used primary key (integer)" and gradually increment it as I will acquire new keys? Or can this information be somehow associated with particular tables (stored in a schema as an attribute of that table)?

Matej Kosik

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070702/10ac76a4/attachment.bin>

More information about the erlang-questions mailing list