[erlang-questions] mnesia: composite keys?
Paul Mineiro
paul-trapexit@REDACTED
Sat Jan 10 20:10:52 CET 2009
On Fri, 9 Jan 2009, Viktor Sovietov wrote:
> If you use ordered_set tables that tuple keys are useful, because you
> can organize hierarchies inside one table. In other hand, you can't
> save such tables on disk, so... Anyway, Erlang isn't MUMPS, so you
> simply have not any mechanism to operate with complex keys.
I have a nonstandard extension to mnesia that allows one to define new
table types, plus a disk-based ordered set table so defined.
http://code.google.com/p/mnesiaex/
Also we use tuples as keys extensively in our application.
-- p
>
> Sincerely,
>
> --Victor
>
> On Jan 9, 11:45 pm, Peter Sabaini <pe...@REDACTED> wrote:
> > Hello list,
> >
> > I've read[1] that mnesia doesn't support composite keys. It seems I can use
> > keys made up of tuples though:
> >
> > (emacs@REDACTED)11> mnesia:create_table(test, [{attributes, [id, data]}]).
> > {atomic,ok}
> > (emacs@REDACTED)19> Ins = fun() -> mnesia:write({test, {a_key, 0}, "asdfasdf"})
> > end.
> > #Fun<erl_eval.20.67289768>
> > (emacs@REDACTED)20> mnesia:transaction(Ins).
> > {atomic,ok}
> > (emacs@REDACTED)21> R = fun() -> mnesia:read(test, {a_key, 0}) end.
> > #Fun<erl_eval.20.67289768>
> > (emacs@REDACTED)22> mnesia:transaction(R).
> > {atomic,[{test,{a_key,0},"asdfasdf"}]}
> >
> > Is tuples as keys common practice or A Really Bad Idea(tm)?
> >
> > thx,
> > peter.
> >
> > [1]http://www.erlang.org/pipermail/erlang-questions/2008-February/032903...
> >
> > signature.asc
> > < 1KViewDownload
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
In an artificial world, only extremists live naturally.
-- Paul Graham
More information about the erlang-questions
mailing list