mysql数据库如何存储分层数据?
我现在以 JSON 形式保存未知数量分支的数据,子级可以有未知数量的子级。
example1 - {employee_1:{employee_2:{employee_3:{}}}}
example2 - {employee_3:{employee_2:employee_1:{}}, employee_4:{employee_3:{}}}
现在要获取此数据,我必须首先获取保存为 json 的层次结构,然后获取存储在该 json 中的 id
有没有办法在一个查询中获取这个?
或者有更好的方法来存储和检索它吗?
我正在使用 MySQL
I am saving data with unknown number of branches in JSON form for now and children can have unknown number of children.
example1 - {employee_1:{employee_2:{employee_3:{}}}}
example2 - {employee_3:{employee_2:employee_1:{}}, employee_4:{employee_3:{}}}
example hierarchical structure
Now to fetch this data, i have to first fetch this hierarchy saved as json and then fetch the id's stored in this json
is there any way to fetch this in one query?
or is there better approach to store and retrieve this?
i am using MySQL
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
员工表
示例 1 员工关系表
示例 2 员工关系表
Employee Table
Example 1 Employee Relation Table
Example 2 Employee Relation Table