Skip to content
YPhotoSharing
Reference · 17/19

Database schema

The tables of a YPhotoSharing 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 SQLite database (yphotosharing.db, configured by database.sqlite.filename). The server creates it; YSocial only reads it.

Time axis

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

Soft removal

Photos and comments are never erased: is_removed or deleted_at flag them, and moderation writes moderation_events.

Shared tables

user_mgmt, stress_reward, user_opinions, memory_* and post_* annotations follow the names of the other platforms.

Three queries to start

Photos and engagement per author:

SELECT u.username, COUNT(p.id) AS photos,
       SUM(p.num_likes) AS likes, SUM(p.num_comments) AS comments, SUM(p.num_shares) AS shares
FROM photos p JOIN user_mgmt u ON u.id = p.user_id
WHERE p.is_removed = 0
GROUP BY u.id ORDER BY likes DESC LIMIT 10;

The current follow graph:

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

What moderation did, by action and content:

SELECT content_type, action_taken, COUNT(*) AS n, AVG(confidence) AS avg_confidence
FROM moderation_events GROUP BY content_type, action_taken;

Where to next

Edit this page on GitHub