Jonny Heggheim
Jonny Heggheim

Reputation: 1453

How to define a foreign key in Mnesia

Is there an equivalent to this SQL statement in Mnesia?

alter table TABLE
add foreign key (FIELD)
references TABLE2 (FIELD2)

Upvotes: 4

Views: 724

Answers (2)

Gordon Guthrie
Gordon Guthrie

Reputation: 6274

There is a library written by Ulf Wiger (formerly of Ericcson, now at Erlang Training And Consulting Ltd) called RDBMS which implements a lot of this for you.

It is quite old so YMMV.

Upvotes: 4

Christian
Christian

Reputation: 9486

No, you have to do all these things yourself in your mnesia transactions. Consistency is your responsibility.

Mnesia is somewhat intentionally simplistic in these features, so it is easy to see the costs in performing queries/updates. The support for secondary indexes on tables is basically the only sugar you get.

Upvotes: 7

Related Questions