惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
MyScale Blog
MyScale Blog
Y
Y Combinator Blog
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
T
The Blog of Author Tim Ferriss
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
N
News and Events Feed by Topic
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 【当耐特】
N
Netflix TechBlog - Medium
博客园 - 叶小钗
B
Blog
Vercel News
Vercel News
T
Tenable Blog
T
The Exploit Database - CXSecurity.com
Spread Privacy
Spread Privacy
T
Threat Research - Cisco Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
F
Fortinet All Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Microsoft Security Blog
Microsoft Security Blog
S
Securelist
Microsoft Azure Blog
Microsoft Azure Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Palo Alto Networks Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
Martin Fowler
Martin Fowler
G
GRAHAM CLULEY
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
A
Arctic Wolf
C
CERT Recently Published Vulnerability Notes
L
LangChain Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Check Point Blog
A
About on SuperTechFans
W
WeLiveSecurity
The GitHub Blog
The GitHub Blog

MySQL Forums

Assistance with MySql application and Sql server MySQL :: MySQL Community Governance Model Announcing June 2026 Releases featuring MySQL Server 9.7.1 and 8.4.10 GoHighLevel Webhook Data in MySQL I&#039;m troubleshooting MySQL query performance (no replies) What could cause .frm and .ibd mismatches across multiple tables? Problem with creating a connection to a remote database on local network Best MySQL schema for storing image processing jobs? APT Repository not working on Ubuntu 26.04 How do you create a remote connection to a database (no replies) MySQL :: storing and reading blob ODBC Connector almost always alters it's name and path MySQL :: Connector/Windows MySQL :: Clientless connection with PS MySQL :: Database wont start Mysql community edition upgrade from 8.0.36 to 8.4 (LTS) (1 reply) Optimizing InnoDB for high-concurrency REST API traffic MySQL :: MySQL Replication issue MySQL :: QUESTION ABOUT FOREIGN KEY : connect --ssl-mode:REQURED< : MYSQL_OPT_SSL_MODE MySQL Workbench Closes when connecting database Optimizing InnoDB for high-frequency concurrent API status updates? MySQL :: Asking for a password Who designed this all but useless tool? MySQL :: MySQL Workbench Announcing April 2026 Releases featuring MySQL Server 9.7.0, 8.4.9 and 8.0.46 MySQL community repo missing package tar.gz package for Debian 13 MySQL Workbench for Ubuntu 26.04 What are the three arguments expected by this script (build_deps.sh)? MySQL :: NO_PUBKEY 9D769D5183E7DDC8 MySQL :: MYSQL 8.4.8 CE - Group Replication MySQL 9.7.0 EA now available How can I implement MySQL connection pooling in a Python Flask or Django application? (1 reply) Tips for Optimizing MySQL Queries for Beginners MySQL :: AWS Ubuntu / MariaDB MySQL :: Alter table variable value Workbench running as background task after start, connect, exit (no replies) MacBook compatbility? (no replies) Announcing January 2026 Releases featuring MySQL Server 9.6.0 Innovation, 8.4.8 LTS and 8.0.45 Announcing October 2025 Releases featuring MySQL Server 9.5.0 Innovation, 8.4.7 LTS and 8.0.44 Announcing July 2025 Releases featuring MySQL Server 9.4.0 Innovation, 8.4.6 LTS and 8.0.43 Announcing April 2025 Releases featuring MySQL Server 9.3.0 Innovation, 8.4.5 LTS and 8.0.42 Announcing January 2025 Releases featuring MySQL Server 9.2.0 Innovation, 8.4.4 LTS and 8.0.41 MySQL Shell for VS Code 1.17.1 has been released Announcing October 2024 Releases featuring MySQL Server 9.1.0 Innovation, 8.4.3 LTS and 8.0.40 Announcing July 2024 off-cycle Releases featuring MySQL Server 9.0.1 Innovation, 8.4.2 LTS and 8.0.39 Announcing July 2024 Releases featuring MySQL Server 9.0.0 Innovation, 8.4.1 LTS and 8.0.38 Announcing April 2024 Releases featuring MySQL 8.4.0 and 8.0.37 Announcing a new webcast video that completes a deep dive into how to download and use Enterprise Manager for MySQL Announcing January 2024 Releases featuring MySQL 8.3.0 and 8.0.36 Announcing October 2023 Releases featuring MySQL 8.2.0 and 8.0.35 Announcing July 2023 Releases featuring MySQL 8.1.0 and 8.0.34 Announcing April 2023 Releases featuring MySQL 8.0.33 Announcing January 2023 Releases featuring MySQL 8.0.32 Announcing October 2022 Releases featuring MySQL 8.0.31 Announcing July 2022 Releases featuring MySQL 8.0.30 : MySQL 8.0.29: Release Notes MySQL Workbench 8.0.24 has been released MySQL Cluster 8.0.24 has been released MySQL Connector/J 8.0.24 has been released MySQL Shell 8.0.24 for MySQL Server 8.0 and 5.7 has been released MySQL Connector/NET 8.0.24 has been released MySQL Connector/Node.js 8.0.24 has been released MySQL Connector/C++ 8.0.24 has been released MySQL Connector/ODBC 8.0.24 has been released MySQL Router 8.0.24 for MySQL Server 8.0 and 5.7 has been released
Two tables with bidirectional relationships
Magnus Mülle · 2026-04-21 · via MySQL Forums

Two tables with bidirectional relationships

Posted by: Magnus Müller
Date: April 18, 2026 10:42AM


Hello,

i am new two MySQL and i am trying to setup my first project which is based on an existing DB (non MySQL).

Now i face a problem.

I have two tables: Departments and Persons. Both tables have unique primary keys.

Each department has a person as head of the department. 1:N This relationship formed no problem.

The second relationship says that every person can belong to a department. But this is not mandatory. So this relationship is 1:N but in the opposite direction.

When i try to send my model to the DB i get a nice little error message (as many i suppose):

Executing SQL script in server
ERROR: Error 6125: Failed to add the foreign key constraint. Missing unique key for constraint 'fk_tbl_persons_tbl_departments1' in the referenced table 'tbl_departments'
SQL Code:
ALTER TABLE `mydb`.`tbl_persons`
ADD CONSTRAINT `fk_tbl_persons_tbl_addresses1`
FOREIGN KEY (`per_adr_index`)
REFERENCES `mydb`.`tbl_addresses` (`adr_index`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_tbl_persons_tbl_departments1`
FOREIGN KEY (`per_dep_index`)
REFERENCES `mydb`.`tbl_departments` (`dep_index`)
ON DELETE NO ACTION
ON UPDATE NO ACTION

I am not sure if i am doing something here which is not possible or what the error might be or how i have to deal with this situation.


Subject

Written By

Posted

Two tables with bidirectional relationships

April 18, 2026 10:42AM

Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.