MER - Temporal confusion of cardinality

Asked

Viewed 472 times

5

I’m having some doubts about the temporal aspect.

Example:

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

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

So far so good, but sometimes I get lost in certain analyses like the one I saw in a booklet:

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

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

That’s the part I get lost in, every time I look at it differently. Therefore, I would only make sense of this phrase if each student is taught by 1 teacher in a given period (in a class). Should you consider the temporal aspect as undetermined (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 get lost in the process.

  • Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?

3 answers

3

You’re complicating it because you’re putting in a variable that doesn’t exist. Forget this temporal thing. It may even be that in some modeling case this variable is relevant and has to consider this, but it has to have a rule that clearly determines that it can only have one at a time.

Of course I don’t know everything about your modeling and might even be doing something that would make sense to look at time, but I think you’re making a normal model of a school. So each student is related to several teachers. Unless, perhaps, it is the beginning of elementary school (even then it is not guaranteed that it has only one). The time in this case is the period the student is enrolled in and not the time the student is in the classroom. If the control was by the time of the classroom then it could be 1 to N (there could also be 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.

1

I think the confusion starts 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 to say, 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 Alunos. In the real world, this concept is a bit absurd, but for relational modeling, it makes perfect sense, because it’s the generic way of expressing relationships.

Now, if the Aluno "has" not Professores, but Aulas taught by Professores, note that the diagram is again associative:

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

Note also that this expression "by function" (i.e., having an "entity" called "teacher") is quite 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 Aulas, Alunos and Professores as follows:

            LECIONA       PARTICIPA DE
[PROFESSOR]N--------<AULA>------------N[ALUNO]

1

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

First part

Books generally do not put the minimum cardinality, only the maximum which can leave the example a little confused.

Imagine in this case that the cardinality is TEACHER (0.1) teaches STUDENT (0.N) see that the translation of this would be:

Any student may or may not take classes with a certain teacher, and a teacher may or may not take classes, realize that the minimum cardinality in the two entities, passes a degree of independence between them, ie, teacher exists independently of student as well as pupil exists independently of the teacher.

Second Part

I also believe that this example is incomplete, realize that there is a missing entity in the middle of teacher and pupil, and her name is discipline.

Every teacher teaches a subject for students.

The biggest difficulty in this example is to understand that there is this hidden entity, because we are talking about an example of ternary relationship, if you do not know what is a ternary relationship I suggest you do a research, it is a little difficult to understand at first.

Follow in the drawing:

inserir a descrição da imagem aqui MER notation of a ternary

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

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

Trying to facilitate understanding

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

The teacher teaches subjects for students

Usually nouns are entities and verbs are relationships.

Substative: The teacher, The discipline, The student.

Verb: To teach.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.