primary key in mnesia

Hakan Mattsson hakan@REDACTED
Mon Jan 26 17:57:19 CET 2004


On Mon, 26 Jan 2004, Mohammad Reza Moosavi wrote:

Mohammad> How can I define a multi attribute primary key for a table?

You can't.

Mohammad> for example a table based on record f:
Mohammad> -record(f,{f1,f2,f3,f4}).
Mohammad> I want to have {f2,f3} as primary key, with no constraint on f1.

Instead you can have an arbritary complex Erlang term as primary key.

You need to redefine your record like:

  -record(f,{f23,f1,f4}).

in order to have {f2,f3} as primary key.


/Håkan

---
Håkan Mattsson
Ericsson
High Availability Software, DBMS Internals
http://www.erlang.org/~hakan/




More information about the erlang-questions mailing list