mnesia foreign keys
Ulf Wiger
ulf.wiger@REDACTED
Mon Jan 19 16:34:39 CET 2004
On Mon, 19 Jan 2004 09:03:58 +0100, Rudolph van Graan
<rvg@REDACTED> wrote:
> 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
http://www.erlang.org/user.html#rdbms-1.3
I have a newer one: rdbms-1.5. Snipped from the README:
"Changes
-------
Changes since 1.3 (1.4 was an experiment never released.)
- A bug that could lead to endless loops during cascading delete has
been fixed.
- 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
complex updates.)
/Uffe
--
Ulf Wiger, Senior System Architect
EAB/UPD/S
More information about the erlang-questions
mailing list