“Follow user” database table design

后端 未结 2 936
广开言路
广开言路 2020-12-24 15:24

I\'m trying to determine the best table design for a \"follow/unfollow user\" feature, similar to Twitter (edit: I\'m not making a Twitter-like application.

相关标签:
2条回答
  • 2020-12-24 15:47

    I would suggest you make follower and following together the primary key. There is no need for a seperate id field.

    0 讨论(0)
  • 2020-12-24 16:05

    I think it's a very good design, and should meet your needs nicely. One thing; you should probably make the follower and following foreign keys. Oh, and for simplicity sake, I'd make the subscribed column TIMESTAMP DEFAULT CURRENT_TIMESTAMP just to capture the datetime the user subscribed.

    0 讨论(0)
提交回复
热议问题