I refer also to this questions that is now almost 3 years old. I have a similar problem.
I have these three tables:
require(data.table)
profile <- data.table(id = seq(11,20))
setkey(profile, "id")
post <- data.table(id = seq(1,10))
setkey(post, "id")
comment <- data.table(post_id = seq(1,10),
profile_id = seq(11,20))
setkeyv(comment, c("post_id","profile_id"))
Now I want to merge profile and post with comment into two different tables. How do I specify that the key to match in comment is profile_id and in post is post_id? Should I respecify how tables are built?