Search code examples
erlangejabberdmnesia

Creating composite key in mnesia


How to create a composite key(key with combination of two attributes) in mnesia table.As far as i know is that the first element in record which we use to create mnesia table is primary key.Please expain with simple example


Solution

  • For example, when use this record

    -record(cuser, {id,login_id,email}).

    to create mnesia table, then the primary key is id, but when you change this recode to this:

    -record(cuser, {{id,login_id},email}).,

    then the primary key is {id,login_id}.

    You can use an tuple as the primary key.