MER - Cardinality temporal confusion

5

I have some temporal doubts.

Example:

[FUNCIONÁRIO]------<PERTENCE>------[DEPARTAMENTO]

In this case it is obvious: each employee belongs to one department, and each department has N employees (either currently or over time).

So far so good, but sometimes I lose myself in certain analyzes like the one I saw in a book:

[PROFESSOR]1------<LECIONA>------N[ALUNO]

Each teacher teaches N students, each student is taught by 1 teacher .

This is the part that I lose, with each different analysis I perceive a different temporal aspect. So, it would only make sense for me to say that if each student is taught by 1 teacher in a given period ( in a class ). If you consider the temporal aspect to be indeterminate ( no longer in one, but in several classes ), then each student is taught by N teachers.

I'm sorry if it's a stupid "doubt", but I lose too much about it.

    
asked by anonymous 28.08.2015 / 10:41

3 answers

3

You are complicating because you are putting a variable that does not exist. Forget this temporal thing. It may even be that in some modeling case this variable is relevant and you have to consider this, but you have to have a rule that clearly states that you can only have one at a time.

Of course I do not know all about your modeling and may even be doing something that would make sense to look at the time, but in I think you are making a normal model for a school. So each student is related to several teachers. Unless, perhaps, it is the beginning of elementary school (even so it is not guaranteed to have one). The time in this case is the period that the student is enrolled and not the time the student is in the classroom. If the control was by the time of the classroom there could be 1 for N (could also have more than one in some situations, but I will not complicate because this is more specific situation). In case it would be a relation from N to M.

    
28.08.2015 / 13:25
1

I think the confusion begins in this analysis:

[PROFESSOR]1------<LECIONA>------N[ALUNO]

In associations 1 to N, there is no associative table between them. You could express the relation as follows:

[PROFESSOR]1---------------------N[ALUNO]

That is, Aluno reference Professor through a foreign key.

On the temporal aspect, everything depends on the goal you have. In the previous example, I know that a Aluno "belongs" to a Professor , and that a Professor "has" N Aluno s. In the real world, this concept is a little absurd, but for relational modeling, it makes perfect sense because it is the generic way of expressing relationships.

Now, if Aluno "has" not Professor s but Aula s taught by Professores , note that the diagram returns to associative:

[PROFESSOR]N------<AULA>------N[ALUNO]

Note also that this expression "by function" (that is, having an "entity" called "teaches") is very problematic. Functions are not entities: they are descriptions of the relationship between entities. Note that it would make much more sense to express the relationship between Aula s, Aluno s and Professor s as follows:

            LECIONA       PARTICIPA DE
[PROFESSOR]N--------<AULA>------------N[ALUNO]
    
28.08.2015 / 16:40
1

I believe that the problem is possibly divided or can be interpreted in two ways or parts.

First part

Books usually do not place the cardinality at all, only the maximum, which may make the example a bit confusing.

Imagine in this case that the cardinality is PROFESSOR (0,1), it teaches STUDENT (0, N) see that the translation would be:

  

A student can have classes or not with a certain teacher, and a teacher can or does not teach, realize that the minimum cardinality in both entities, passes a degree of independence between them, that is, strong> exists independently of student as well as student exists independently of the teacher.

Second Part

I also believe that this example is incomplete, realize that an entity is missing in the middle of teacher and student , and it is called discipline .

Every teacher teaches in a discipline for the students.

The biggest difficulty in this example is to understand that there is this hidden entity, as we are talking about an example of a ternary relationship, if you do not know what a ternary relationship is, I suggest you give it a look, / p>

Follow the drawing:

Ternary MER notation

See that the 3 entities exist independently of each other, but try to take one of them and you will see that it loses meaning, in practice this ternary will be broken up into 3 relationships of type 1: M and will give rise to a new table serving as support for all three.

This new entity will save the foreign keys of the others as the primary key itself.

Trying to make it easier to understand

I usually fit a ternary into a phrase with subject and predicate, for example:

The teacher teaches subjects to the students

Usually nouns are entities and verbs are relationships.

Substitutes: The teacher, The Discipline, The student.

Verb: Teaching.

  

Note also that the verb to teach is transitive direct and indirect, that is, who teaches, teaches something (discipline) to someone (student)

    
03.11.2017 / 05:41