Jump to content

MariaDB: Inter-database foreign keys


sagnik

Recommended Posts

Hi, is there any way to create a foreign key linked to another database? I can't see all the databases in PMA.

Link to comment
Share on other sites

This does not appear to be supported on Plesk (though it technically is possible in mariadb). It's generally considered to be poor practice anyway, insomuch that mysql/mariadb is one of the only major engines that even supports it. Postgres and SQL Server expressly refuse to support this (in Postgres you can do it between schemas but not databases, and sql server simply has no support at all, you need to use triggers).

Allowing this actually causes all sorts of issues with database integrity too, for example, what happens if one of the two databases goes missing or is rolled back to a backup?

  • Like 1
Link to comment
Share on other sites

@wolstech Okay, I got your point. But I have a centralized login system for all the services/platforms which uses a database called "members" and the tables (specifically, "accounts") in it and a specific column of that table namely "uid" as a foreign key relation, i.e. if a row of that table is deleted this would delete all the information located throughout all other databases related to the "uid".

Please let me know if there are any other ways to achieve this.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...