我正在讨论数据结构 . 我有一个项目列表,可以是 public
或 per-user
. 这是我的两个选择
//1
items:
item1 { authorId: "system" }
item2 { authorId: "user1" }
//2
items:
system
item1 { }
user1
item2 { }
//3
items:
item1 { }
item2 { }
user-items:
system { items: {item1: true} }
user1 { items: {item2: true} }
Structure 1 :
-
更难查询
-
我不需要知道要查询的项的类型(我需要的只是id)
Structure 2 :
-
更容易查询
-
可能性能更好
-
我需要知道项目是公共的还是每个用户才能查询它
Structure 3 :
-
更灵活
-
需要多个查询来获取预期数据(获取用户项,获取项ID,然后为每个id获取项目)
有什么建议?