Mnesia and uniqueness on two keys

Ulf Wiger ulf@REDACTED
Wed Jul 13 15:10:16 CEST 2005


Den 2005-07-13 04:00:08 skrev Joel Reymont <joelr1@REDACTED>:

> I'm obviously missing something. What is a key then?
>
>      Thanks, Joel
>
> On Jul 13, 2005, at 1:38 AM, Sean Hinde wrote:
>
>> Nowhere does the documentation claim that an index is part of a key.

In database parlance, a 'key attribute' uniquely identifies a
record.

An 'index' is a structure that, given an attribute value
points to one or several actual objects. The attribute
value used by the index is called an 'index field'.
A 'primary index' uses the primary key as its index field,
thus producing a 'dense index' (where each index value
always points to exactly one object). An index that uses
another key attribute in the object is called a 'secondary
index', and the index field in question a 'secondary key'.
Thus, you can define an index on an attribute, but you
cannot tell mnesia that the attribute is a 'key'
attribute (i.e. unique).

An ets 'set' or 'ordered_set' table can be seen as a
primary index. Mnesia also supports indexes on non-key
attributes, but has no notion of 'secondary keys'.
In Mnesia, the 2nd element of the record is always the
primary key (if 'set' or 'ordered_set'). I know of no
good RDBMS terminology for 'bag' tables, since such
tables are not part of the relational database model.

Furthermore, all attributes in mnesia are considered
atomic -- there are no composite attributes. Thus, you
cannot index a combination of attributes, or part of an
attribute.

/Uffe




More information about the erlang-questions mailing list