search

Home  >  Q&A  >  body text

mysql - 类似QQ的好友关系表是怎么设计的?

请问一下类似QQ的好友关系表是怎么设计的?
难道只是简单的id,userId,friendId吗?

迷茫迷茫2780 days ago3328

reply all(12)I'll reply

  • 阿神

    阿神2017-04-17 14:48:10

    I have done such a simple design before, but it depends on your needs.
    1. User table
    id, name
    For example data:
    1, Zhang San
    2, Wang Er
    2. Friend table
    id, u_id, c_id
    For example, data
    1,1,2 (representative) Zhang San plus Wang Er
    2,2,1 Wang Er plus Zhang San

    Relatively simple idea, I hope it will be helpful to you.

    reply
    0
  • PHPz

    PHPz2017-04-17 14:48:10

    If the volume is small, it is okay to only use a relational database. If the volume is large, you have to consider non-relational ones, such as graph databases

    reply
    0
  • Cancelreply