Is there a way to make primary key and foreign key relationship with Parse tables? If yes, how?
有没有办法与Parse表建立主键和外键关系?如果有,怎么样?
I've two tables:
我有两张桌子:
User Table:
uId (primary key/string) | uName (string) | uAge (number) | uGender (string) | uLocation (string)
uId(主键/字符串)| uName(string)| uAge(数字)| uGender(字符串)| uLocation(字符串)
Employment Table:
eId (unique/string) | eType (number) | eSalary (number) | uId (foreign key/string)
eId(唯一/字符串)| eType(数字)| eSalary(数字)| uId(外键/字符串)
So that, if I'll delete an entry from User table, it'll delete all entries for that particular user in Employment table.
因此,如果我将从User表中删除一个条目,它将删除Employment表中该特定用户的所有条目。
1 个解决方案
#1
The objectId
created by parse is the unique identifier. There is no concept of a primary key from the point of view of indexing, just unique identification.
parse创建的objectId是唯一标识符。从索引的角度来看,没有主键的概念,只有唯一的标识。
A pointer or relationship is the approach you should use to foreign key linking
. This is effectively a link to the foreign object objectId
.
指针或关系是您应该用于外键链接的方法。这实际上是指向外部对象objectId的链接。
There is no automatic deletion logic. To accomplish that you would use a before delete cloud trigger to process and cascade the deletion to the linked objects.
没有自动删除逻辑。为此,您将使用删除之前的云触发器来处理并将删除级联到链接对象。
#1
The objectId
created by parse is the unique identifier. There is no concept of a primary key from the point of view of indexing, just unique identification.
parse创建的objectId是唯一标识符。从索引的角度来看,没有主键的概念,只有唯一的标识。
A pointer or relationship is the approach you should use to foreign key linking
. This is effectively a link to the foreign object objectId
.
指针或关系是您应该用于外键链接的方法。这实际上是指向外部对象objectId的链接。
There is no automatic deletion logic. To accomplish that you would use a before delete cloud trigger to process and cascade the deletion to the linked objects.
没有自动删除逻辑。为此,您将使用删除之前的云触发器来处理并将删除级联到链接对象。