How to model the following requirement in ER-Diagram

database-designerdschema

I'm making a story-composer application which allows users to write stories and other users can contribute to it. A story can have multiple storylines and multiple levels(think like a tree or thread structure). Following are the constraints :

  1. When a user creates a story, they need to give it a title to the story and write a storyline.
  2. Creating user can make the story public or private, if public, anyone can contribute to it, if private, the creator needs to invite specific users to contribute to it.
  3. Bookmark Feature : There will be a checkbox besides each thread(storyline) and title.
    1. If user checks the checkbox besides story title then the entire story is bookmarked or
    2. User can bookmark specific storyline(s) by checking checkbox besides it.

Best Answer

I think you could do this with three tables and a view, User, Bookmark, Story_View and Story. User would contain all the users (log in information and an ID).

Story would contain a field in which you could put whatever the story is then when you want another user to modify that story you could just select that story and make a new record adding on whatever the next user adds on. Also it would have a number primary key as well as a foreign key to user ID so we can select the original owner of the story.

Story View would be what the users actually see. Users would only be able to see the data for stories they have made or are able to write on. There's definitely a better way of doing this using something outside of SQL.

Bookmarks table would simply store a foreign key to both user and story every time a user adds something to their bookmarks a record would be added to the bookmark table containing the user Id and story id so you could easily use a user ID to select all that users bookmarks.

I'm not going to draw a diagram because I think it's pretty easy best on this design.