How can I create and use (or simulate) multi-column indexes in Erlang Mnesia


I have looked through the Mnesia documentation and the 3 popular Erlang books. It seems only single column primary and secondary indexes can be created and used. Or maybe it is just what the examples cover? If I create a separate index on each of the columns will/is Mnesia able to use them intelligently together to simulate multi-column key index searches? If so would the performance be much better than a simple table scan?

If multi-column indexing is not supported by Mnesia, given its a native dbms has anyone simulated this functionality in Erlang.

Second Qestion: How about simulating constraints (referential, check), triggers and event-based notifications?

One way is to store {X, Y} directly in the "column" that has the key. This makes you able to search fast on queries of structure {_, _} but it also means slower searches when you only know one of the values in the tuple (By default, the tables are hash-tables).

As for your other DBMS wants: Mnesia was not really built to replace traditional databases as much as it was built to satisfy the needs of the Ericsson devs when writing their applications. Thus, you may be better off by storing data in a traditional database, if that is what you are aiming for.

You may be able to add the functionality with code around mnesia however - if that is what you want.