A real consumer facing implementation would be much more complex than that. Here are a few simple changes to the schema to make the implementation little more efficient:
The like count should be an integer field(column) in each post record (row in the table).
Like table should be indexed on author (assuming author/username is unique). A safer approach is to use an userID as foreign key.
The like relationship between post and user should be cached for better read performance. For each user we can use a set datastructure to cache the post IDs of liked posts.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
A real consumer facing implementation would be much more complex than that. Here are a few simple changes to the schema to make the implementation little more efficient:
The like count should be an integer field(column) in each post record (row in the table).
Like table should be indexed on author (assuming author/username is unique). A safer approach is to use an userID as foreign key.
The like relationship between post and user should be cached for better read performance. For each user we can use a set datastructure to cache the post IDs of liked posts.