Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
like image 292
Jonny Heggheim Avatar asked Dec 23 '22 10:12

Jonny Heggheim


2 Answers

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.

like image 90
Christian Avatar answered Dec 25 '22 22:12

Christian


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.

like image 32
Gordon Guthrie Avatar answered Dec 26 '22 00:12

Gordon Guthrie