3 ms·
Facebook was very similar, I believe. The MySQL schema boiled down to two tables: nodes with an id, a type, and key/value properties; and edges (known interna
by gorgoiler 4y ago
Facebook was very similar, I believe. The MySQL schema boiled down to two tables: nodes with an id, a type, and key/value properties; and edges (known internally as assocs) between pairs of ids, also with key/value properties and a type.
A simple schema helps when you just need to write stuff. You can make simple queries against a simple schema, directly.
For the juicier queries what you do is you derive new tables from the data using ETL or map/reduce. The complexity of the underlying schema doesn’t have to reflect the complexity of your more complicated queries. It only needs to be complex enough to let you store data in its base form and make simple queries. Everything else can be derived on top of that, behind the scenes.
Example: nodes are people and edges represent friendships, and then from this you could derive a new table of best_friend(id, bf_id, since).