Relationships in my database

1

I have a doubt as to which 3 tables would do practically the same, Save the urls of where the files are located

I have a table called Groups - where you can save files, in general it's just uploading files. And already in their respective group. (He already does)

Grupo -  Archivos 

Then in the same Group. There is a task section

Simulando un Classroom

In said group: a Task is published by a teacher Then

He uploads the task, but also uploads Files.

Then I would have another table called

 Tareas - ArchivosTareas

Then, when a student wants to upload their assignments, he also needs to upload files .. of whose task. that would be like this

Entrega - ArchivosEntrega

So that's where I have doubts about using that form the relationship, since I do not know if this is optimal. for the same reason, repeat tables with the same objective of saving files.

This is my Design:

I explain my relationships:

a user can create groups, so in the table group, there is a field that says who created whose room.

Then another user, You can register to that group, that's why the pivot table is. To make the relation that a user can be registered to several groups

Then where it says group, it can have many tasks, and it can also have many files

in the task table, you can make many files that a teacher has uploaded. To download the material

Then in files, the relationship goes to users, to say that a user can upload several files.

that is the most revealing in case a doubt arises. because the rest is what I mention, I do not know if I have to make 3 tables for each of the files.

I do not know if this is well done, or that there is a better way to do it!

Since in eloquent

the way to access them is very easy. good to some extent.

Ignore the data that is still missing from my tables as soon as. I just need to understand the relationships of themselves

    
asked by Alex Burke Cooper 20.11.2018 в 04:04
source

1 answer

0

Have a table for each "type" knowing that its internal structure is the same, is a symptom of bad normalization since you are skipping the 1FN and 2FN, which avoid redundancy and create inconsistency in the data and the model . You should have a single table called "files" (in English and lowercase is better: files) and add a column that indicates the role that has uploaded "role_id", then you will have a table of roles that indicates whether the user (user_id ) is a teacher and / or student (role_id) since you can have both.

    
answered by 29.11.2018 в 22:43