Effective design and management of a user settings module

I do not know if this type of question has already been asked or not. Actually, I don’t know what to look for. I ask in the right place?

As an example , I’m always wondering how giants of social networks such as Facebook manage their user settings module ... What will the database design be and how do they manage to hide user updates on their own when he decided not to show his updates on this particular timeline friends. I mean, if I programmed there, I would load all the parameter values ​​into an array, and there would be many conditional statements to check each user parameter and accordingly the printed data.

But I think that would make this code unmanageable, because there would be so many conditions that could lead to undesirable results.

So my question is: is there a better way to do this?

I don’t know how I feel here, but I tried to explain my question.

+5
source share
4 answers

Facebook data is stored in a document repository (Nosql), and effective indexing is used for quick tag searches and searches. This approach to searching and storing data is markedly different from storing and searching data based on relational databases.

Google also uses a similar scheme to display the entire network and quickly returns the result.

Thus, in simpler terms, data is stored and indexed like Google indexes messages, the only difference is that the data also lies with Facebook.

Related technologies Bigdata , Mongodb , Apache Hadoop . And one of the leading index management and search algorithms is Lucene . Apache Elasticsearch is a convenient package for Lucene.

Thus, facebook considers these critical security measures, such as a tag (in plain language), and makes google like a search and presents you with a nice interface, not like a search engine.

When setting up your system, you can use elasticsearch to speed up the search. Elasticsearch simplifies the implementation of lucene. He will definitely have a certain learning curve. Elasticsearch can also be used with rdbms , in which case your data is stored in a database, but indexes are also supported for faster searches. It will definitely be disk space. This allows you to have many criteria, but still allows you to quickly get the result.

Quick tutorial on elasticsearch.

+3
source

There would be a lot of conditions for evaluation, this is correct. But in a SELECT you can easily make all these conditions in WHERE , which is very efficient.

In fact, while you are comparing equality, the database can easily optimize this, allowing you to quickly search for messages that meet the required restrictions. Despite the fact that there are many conditions, they do not affect performance compared to the fact that there are millions of records in the search table.

+2
source

What you ask is the result of very hard planning .. whenever you need to develop something that has a good potential to be complex, you will have to plan (engineering) it well, using well-known methodologies.

Usually, a database has a lot of polymorphic relationships with entities, there are guys who are responsible for recording query procedures that should receive the required data fairly for developers.

This is really not something you could come up with a simple solution, the key here is planning and planning. there is not a single correct answer.

If your application is quite small, you can simply implement it in your own way, then you will see that you can upgrade. This is pretty much your only way. (By the way, what most statuses do)

Wish you luck.

+2
source

Regarding the facebook db scheme and how it works, and why its design is good, here are some articles that would explain to you why:

Power chart

This is posted on facebook and it explains how they manage data. They use the TAO data model, and through the application of graph theory and other complex algorithms and advanced caching and data processing, they can effectively manage a variety of user data.

but regarding your question:
What will the database design be and how do they manage to hide user updates on the friends timeline if he decides not to show his updates on this particular friends timeline?

  • I think this post will give you some idea of ​​what the structure of facebook db structure is and what its functionality is for each user: Social networks Friends Database related projects

  • Usually hiding user updates on your friends timeline, if you didn’t show your update to this particular friend, is controlled by storing the values ​​in the database .. you can create a view_type table in db and which will determine what kind of user the user can see, then output the where clause in their sqls based on the user selected by the user. There are many more ways to handle this, and a good database structure is required for this, and, of course, planning a good and efficient database is a very important and rigorous procedure.

+2
source

Source: https://habr.com/ru/post/1213404/


All Articles