In my application a user can post comments against either a post or a reply to a post. This is NOT the same as nested comments as the reply is a different table to the comment. I guess this is very similar to the way in which StackOverflow works.

I'm confused about how to link it though as what would the foreign key be? As normally I'd just put post\_id in the comments table but I also need reply\_id to link it to the answer IF its linked to that rather than the actual post. Although I guess I'd need both in that instance so to link to the post and the reply on that post although the reply itself is already linked... confusing right?

What's the best way to do this? Thanks

```
POSTS
id
title
content
datetime

REPLIES
id
datetime
content
post_id

COMMENTS
id
datetime
content
post_id
reply_id

```