database - Way to implement Data Model ( activities feature ) -


i have generic architectural question of data model. have social network. network has standard functionality such

  • add friends;
  • add photos;
  • change profile;
  • e.t.c;

each of them actions begets different notifications (or activities) cab views in special screen user's friends. example can see similar functionality in instagram. looks like:

enter image description here

in fact feature popular feature in screen. result personality , can't cached effectively.

so, according or vision can propose 2 variants how can storage data:

  1. we can prepare list of notifications each user in moment when events occurred. allows reduce difficulty of query during getting activities. have load after each event. imagine user has 500 000 friends, each of them should see activities, need make 500 000 inserts in feeds of each user. therefore have additional overhead disk space , cpu.

  2. second approach saving notification in single instance in table, , composing feed each user during extracting notifications. have no overhead disk, have hard query (grouping, subselects, many joins e.t.c) during getting notifications.

currently moved functionality in dedicated service , think datamodel of service. have ideas or maybe articles approaches can usefult us. thank in advance.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -