'Followers' and efficiency

后端 未结 4 1409
别那么骄傲
别那么骄傲 2020-12-28 09:57

I am designing an app that would involve users \'following\' each other\'s activity, in the twitter sense, but I am not very experienced with database/query design/efficienc

相关标签:
4条回答
  • 2020-12-28 10:38

    You probably should read http://highscalability.com/ and it's articles on how this is managed by the big sites.

    0 讨论(0)
  • 2020-12-28 10:55

    That depends on how many users you expect to need to support; how many followers you expect users to have; and what sort of funding/development-effort you expect to have access to should your answers to the previous questions prove optimistic.

    For a small scale project I would likely ignore the database, design the application as a simple object model with User objects that maintain a List[followers]. Keep it all in RAM for normal operation and use an ORM to persist to a database periodically (probably postgresql or mysql).

    For a larger project I would not be using a relational database at all; but exactly what I would use would depend on the specific details of the project.

    If you are only trying to spike the concept, go with the ORM approach; but, keep in mind it won't scale.

    0 讨论(0)
  • 2020-12-28 10:58

    The model is fairly simple. The problem is in the size of the Subscription table; if there are 1 million users, and each subscribes to 1000, then the Subscription table has 1 billion rows.

    0 讨论(0)
  • 2020-12-28 10:59

    Pretty simple and easy to do with full normalisation. If you have a table of users, each with a unique ID, you would have a TABLE_FOLLOWERS table with the columns, USERID and FOLLOWERID which would describe all the followers for each user as a one to one to many relationship.

    Even with millions of assosciations on a half decent database server this will perform well and fast as long as you are using a good database (IE, not MS-Access).

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