Say I have a database with 3 tables: Stream
, Tag
and Post
- Stream has one tag. Multiple streams can have the same tag.
- Stream is owned by one user.
- A tag has many posts.
- Different tags can have the same post.
- Each user that opens his stream gets it's posts (via the tag) and can delete (or hide) the posts he doesn't want to see (but only for him, not for others).
What would be the appropriate way to achieve this? Obviously I'll need some kind of soft-delete flag on posts. I currently have 2 ideas in mind:
- Create another table that will act as the view of the stream with columns
stream_id
,post_id
andis_deleted
- Add
deleted
column toStream
that holds a JSON array of deleted posts' ids. The problem with this approach is querying based on is_deleted state.
Are there any better ways?
Note: Currently, I need Tag
to stay in it's own table, rather than storing it as text in a column in Stream