I'm trying to understand the terminology around forward vs backward references in CloudKit.
Say I have two record types:
- User
- LeaderboardScore (a score belongs to a user)
The score record stores a user reference:
score["user"] = CKRecord.Reference(
recordID: userRecordID,
action: .deleteSelf
)
So:
- LeaderboardScore → User
- The user record does not store any references to scores
From a data-model perspective:
- Is this considered a forward reference (child → parent)?
- Or a back reference, since the score is "pointing back" to its owner?
My use case is having leaderboard in my app and so i have created a user table to store all the users and a score table for saving the scores of each user of the app.
In CloudKit, a reference (CKRecord.Reference) is a forward reference, that stores a field pointing to another record’s ID. In your case, LeaderboardScore.user is a field points to a user (User), and the user doesn't have anything pointing back to the leaderboard score.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.