Creation Related bank

1

I have a question about whether or not I'm setting up this bank. They could help if the path is right or wrong. For now I just put id in the tables.

Class

Turma | Turmaid
    A  1
    B  2
    C  3
    D  4

Municipality

   Municipio | municipioid
   municipioA  1
   municipioB  2
   municipioC  3
   municipioD  4

Teacher

Professor | turmaid | municipioid 
  José      3            1
  Maria     2            2
  Allna     4            3

Student

 Nome | turmaid | municipioid | ano_ensino
 Joao      1            1         1º
 Cezar     2            2         7º
 Thiago    2            3         5º

I am doubtful because a student can have multiple teachers or just one, just as the teacher will have several students. I need the teacher to list his students in a moment. And that in admin I know what teachers that student has.

Would it be so?

    
asked by anonymous 03.10.2015 / 05:57

1 answer

2

Relationship between entities is the type of occurrence between entities .

Relationship types:

There are three types of relationship between entities:

one-to-one

one-to-many

many-to-many

In your case the relationship applies many to many N: N.

You can define the relation as follows:

Cardinality

Cardinalityisanimportantconcepttohelpdefinetherelationship,itdefinesthenumberofoccurrencesinarelationship.Todeterminecardinality,onemustasktherelationshipquestioninbothdirections.

Doesateacherhavehowmanystudents?

  • aminimumof1andamaximumofN

Isastudentallocatedinhowmanyclasses?

  • aminimumof1andamaximumof1

Addingthecardinalities,wedefinethefinalresultoftherelationship,thatis,1:N

More information here.

    
03.10.2015 / 17:19