Skip to content
YSimulator
Reference · 13/14

Database schema

The tables of a YSimulator run, ready for SQL, pandas or the admin analytics.

In short

  • Goal. Find a table, read its columns and see how it links to the others.
  • Time. reference

Everything that happens in a run ends up in one database (SQLite by default, simulation.db; PostgreSQL or MySQL by configuration). The server creates and writes it; YSocial only reads it.

Time axis

rounds has one row per simulated hour (day, hour); other tables point to it with round, round_id or tid.

UUID keys

Ids are UUID strings, which suit a distributed run; a comment is a row of post whose comment_to is not −1.

Shared tables

user_mgmt, stress_reward, agent_opinion, memory_* and the annotation tables follow the names of the other platforms.

Three queries to start

Posts and reactions per author:

SELECT u.username, COUNT(DISTINCT p.id) AS posts, COUNT(r.id) AS reactions
FROM user_mgmt u
LEFT JOIN post p ON p.user_id = u.id AND p.comment_to = '-1'
LEFT JOIN reactions r ON r.post_id = p.id
GROUP BY u.id ORDER BY reactions DESC LIMIT 10;

The current follow graph:

SELECT follower_id, user_id FROM follow WHERE action = 'follow';

Mean opinion per topic and day:

SELECT i.interest, rd.day, AVG(o.opinion) AS mean_opinion
FROM agent_opinion o
JOIN interests i ON i.iid = o.topic_id
JOIN rounds rd ON rd.id = o.tid
GROUP BY i.interest, rd.day ORDER BY rd.day;

Sort by time through rounds (day, hour), not by id: UUIDs have no order.

Where to next

Edit this page on GitHub