[erlang-questions] Mnesia and autogenerated ids

Christian S chsu79@REDACTED
Thu Aug 7 21:57:11 CEST 2008

Here are some previous threads on the same topic.




To summarize,

 * use {node(), now()} as the least-effort approach

 * more effort: create a mnesia table {sequences, TableName, Serial}
with a row per table, increment numeric id in it for a new id

 * even more effort, have each node allocate many ids directly, and
use them up in subsequent transactions on that node before you get a
chunk again. this is to lower total amount of transactions to the
sequence table.

If you can, there is the possibility to erlang:md5 on some data in
that row record, and using the md5 as a unique primary key.

On Thu, Aug 7, 2008 at 8:32 PM, Luke Galea <galeal@REDACTED> wrote:
> Hi all,
> I'm trying to get my head around mnesia. It seems great so far, but
> I'm struggling with the lack of autogenerated ids to have one table
> refer to another. I'm on board with having less normalized data
> requiring fewer tables and thus fewer references.. But when a
> reference is required, is there no "easy" way to reference another
> table without using a natural key (like "user_name", etc)?
> I see that I could have a gen_server that serves up ids.. but is there
> a better way to do this? It seems an unnecessary bit of complexity to
> support if everyone ultimately needs to do this.
> Thanks in advance
> Luke Galea
> http://www.ideaforge.org
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list