How to enter data to multi-linked tables

-1

Maybe the title is not well formulated, but my question is this, the teacher put these tables together

but when entering values I must put data that I obviously do not have yet because everything enters a vicious circle where I can not (or do not know) start anywhere. What would be the best way to do it? Enter the

  

ALTER TABLE MATTER ADD DNI_ALUMNOS INT FOREIGN KEY REFERENCES ALUMNO

after already entering values?

    
asked by Jose Luis 09.03.2017 в 07:05
source

2 answers

0

Although your question is a bit convoluted, I think I understand your problem. The problem you have is that you are relating master tables with detail tables. Let me explain, the students table is a detail table and the material table is a master table (like the race table). If you do the relationship directly you would have to repeat records in the tables of carrereas and matters. To make these relationships should be (I think I have not left any):

  • MATERIA-> CARRERA
  • MATTER-> TEACHING
  • STUDENTS RELATIVE ALUMINUM < - & MATERIA (because a student can have more than one subject)

Students do not have to relate to teachers because they are related by subject, since a student will have more than one subject and, therefore, more than one teacher.

It's easier if you think about it naturally and then you move it to tables if you try to fight directly with tables.

It has been a bit long but I hope it will help you.

    
answered by 09.03.2017 / 09:36
source
0

Conceptually the 4 entities or tables, are teachers, and are not directly related to each other. Relationships begin to be seen through "detail" tables

For example:

  • A career has several subjects, the same subject can be repeated in several races, each subject according to the degree has a teacher. So we could have a detail that is: CarrerasMateriasTecentes, with the Race Id, those of each Matter (1-N), and those of the teacher for the subject / career (1-1).
  • A student could eventually follow more than one race, so there we would have a table AlumnosCarreras

With these two tables, I think we handle all the relationships of this model

Greetings ..//

    
answered by 09.03.2017 в 16:12