mnesia foreign keys
Mon Jan 19 16:34:39 CET 2004
On Mon, 19 Jan 2004 09:03:58 +0100, Rudolph van Graan
> Hi all,
> I am thinking of how to get mnesia to enforce foreign key relationships
> in our database. I.e. to get some key-violation when you delete a record
> on which another record in the same or another table depends.
> Looking at the Mnesia user's guide, this section seems to imply that
> such functionality already exists. Can someone explain to me how to use
> this? Is it possible to use this foreign key mechanism for what we need?
> I think I once read that Ulf Wiger had written some Relational DB
> library for mnesia?
You will find the rdbms contrib at
I have a newer one: rdbms-1.5. Snipped from the README:
Changes since 1.3 (1.4 was an experiment never released.)
- A bug that could lead to endless loops during cascading delete has
- New options: 'add_references', 'drop_references' make it easier to
plug in new dependencies when new tables are created.
- Exported functions, create_table/2 and delete_table/1 allow for more
integrated handling of rdbms options. delete_table/1 will clean up
dangling referential integrity options automatically."
One of these days I'll get around to putting it up in the jungerl,
but for now, I can send you the latest version if you're interested.
BTW, the semantics of rdbms's referential integrity checking
follow the SQL/92 standard semantics (i.e. CASCADE, SET_NULL,
SET DEFAULT, and IGNORE -- with some restrictions for the
finer points of guaranteeing predictable behaviour during
Ulf Wiger, Senior System Architect
More information about the erlang-questions