## EMS Database 

---



### 1. Relationship of menu, account, account_menu, title_info


![1679033737734](image/database/1679033737734.png)

通过多表联合查询可一次性获取某个账号的目录结果：

example, acouunt name='manager', lang-key='cn'：

```sql
SELECT m.id, json_unquote(json_extract(t.title_json, '$.en')) as title, m.parent_id, m.sort_id FROM title_info t, menu m WHERE m.id IN (SELECT am.menu_id FROM account_menu am WHERE am.account_id = (SELECT id FROM account WHERE name='manager')) AND m.title_id = t.id ORDER BY m.id
```
