I'm having difficulty on designing a database schema design with the right relationships. I'm currently trying to design a database system where a question
can be answer via a live_stream
. The general idea is that a user
can ask a question
. Then a user
can answer
the question and set a live_stream
. Many users
can join that live_stream
. Here is the diagram. https://dbdiagram.io/d/5f2a06ce7543d301bf5de918
I have added a link to the schema design where you can navigate the relationships. But basically the idea is as follows.
A user can create many questions.
user
1 -> *question
A question belongs to a user
A user can like a question
user
1 -> *likes
,A question can have many likes by users.
question
1 -> *likes
A question has one answer
question
1 -> 1answer
and an answer belongs to a user
user
1 ->answer
Here is something I have struggle with. Basically I have created a join table for a many to many relationship between users
and answers
. Using live_streams
as the join table. The way I see it is that many users
can watch the explanation of the live_stream for the answer
and the answer
can have many users watch the live_stream
. Also I added presenter
to the live_streams
table. The presenter
is also a user
.
Many users can join a live stream
users
1 -> *live_streams
A live stream belongs to an answer
answers
1 -> *live_streams
A user is a presenter of the live stream
user
1 -> 1live_stream
I'm still a but skeptical about the way live_streams
table works as a join table between users
and answers
. Is still clear to me that many users can join a live stream. but not sure if the relationship between answers
and live_streams
should be a one to many, but I see it as live_stream
belongs to answer
.
The user presenting the live stream has to be the person who answered the question. So if the answer
belongs to a user
, that same user
should be the presenter
in the live_streams
table. The answers
table works more as setting the time, description and name of when the live stream is going to take place.
Is this correct? I'm open to feedback as to how to improve the design or if there is any errors in the logic.
And are we sure each question will have at most one answer, or is it one accepted answer.
I was thinking it would be easier at first to just have one answer.