D
D
Daniil Chashkov2021-12-04 20:09:58
Database design
Daniil Chashkov, 2021-12-04 20:09:58

How can I make a consistent structure in the database (ER-model)?

The bottom line is that all tables should be connected sequentially, there should not be circular connections, as it is now in the diagram.
There are tables Users, Projects, Tasks, Messages.
The user can create a project, tasks in the project. When you create a project, a chat belonging to this project is created. All users in the project can write to this chat.
Users can create tasks in a project that have fields:
- project_id (id of the project to which the task belongs)
- creator_id (id of the creator of the task)
- performer_id (id of the performer)

The point is that the user is associated with the project once, and now he is connected three times: via chat, via task and directly
61ab9fc8d9776486564021.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2021-12-05
@imnotwhoexpect

In Taskshould be references not to User, but to Project_User (id). After all, only those who work with the project can create and perform tasks.

a chat belonging to this project is created
Why are you the opposite? Several projects are linked to one chat.
If the chat is limited to project members, then you can delete Chat, and in Messageshould refer to Projectand Project_User (id).
And in Project_Userthere should be a link to a separate table Role (ID, Name). Don't break third normal form.
I propose a universal structure Chat:
ID
Name. "Game" for example.
ProjectProject, "Game, balls", for example. If NULL - common.
RoleRole - group by role, "Game, balls, tester", for example. If NULL - common for the project. If the project is also NULL, it is generic by role. "Game, tester", for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question