Why the first element of a record can't be used as table index?
This is not working:
(hlu@192.168.0.40)16> rd(pilot, {id, name, weight, phone}).
pilot
(hlu@192.168.0.40)17> mnesia:create_table(pilot,
(hlu@192.168.0.40)17> [{attributes, record_info(fields, pilot)},
(hlu@192.168.0.40)17> {index, [#pilot.id]},
(hlu@192.168.0.40)17> {disc_copies, Nodes},
(hlu@192.168.0.40)17> {type, set}]).
{aborted,{bad_type,pilot,{index,[{2,ordered}]}}}
This is working:
(hlu@192.168.0.40)18> rf(pilot).
ok
(hlu@192.168.0.40)19> rd(pilot, {name, weight, phone, id}).
pilot
(hlu@192.168.0.40)20> mnesia:create_table(pilot,
(hlu@192.168.0.40)20> [{attributes, record_info(fields, pilot)},
(hlu@192.168.0.40)20> {index, [#pilot.id]},
(hlu@192.168.0.40)20> {disc_copies, Nodes},
(hlu@192.168.0.40)20> {type, set}]).
{atomic,ok}
I've found a single statement in the documentation:
The first record attribute is the primary key, or key for short.
Later on:
index. This is a list of attribute names, or integers, which specify the tuple positions on which Mnesia is to build and maintain an extra index table.