mnesia primary key creation

Matthew McDonnell matt@REDACTED
Fri Jun 30 10:13:33 CEST 2006

On Thu, 29 Jun 2006, Roberto Saccon wrote:

> I am wondering whether experienced erlang developers have something
> better in their best-practises-treasure-box than what I have come up
> with to create mnesia primary keys:

(not an experienced erlang developer)
I use a separate process to act as a server to access the database, with
the state of the server containing the last primary key used.  Something
like the following:

loop(Key) ->
    {From, {add, Record}} ->
      <mnesia transaction to insert {Key, Record}>

More robust solution is to do this in an OTP application with a gen_server
that can get restarted if it crashes, recalculates last Key when
intialised, is registered with a name eg mnesia_server, etc


Matt McDonnell
Email: matt@REDACTED

More information about the erlang-questions mailing list