Search This Blog

Loading...

9/15/2011

Care about Entity-Relationship Model

Entity-Relationship Model is the famous model of databases and their entities, properties and relationships.

At first, it looks a simple model if we concentrate in the reality. This is true, if the properties of each entity and the relationship between entities are realy consistent with truth at any condition. It is important to take care about the names used for each entity and the point in wich they can be broken into other entities to avoid duplicate data.

Although, there are details that I have saw recently: I think there is a natural trend for modelers to link some entities to entities that represent actors (people) instead of linking where they really would need to be linked (to preserve the referential integrity).

For example, let's take these entities:

  • student (a student of any course)
  • person (any person of the planet)
  • discipline offer (a discipline offered in a period by a teacher)
  • evaluative activity (activities that students enrolled in discipline offer should do to take a grade)
  • enrollment (entity that represents the relationship between a student with a discipline offer, indicating that the student is enrolled in the discipline offer)
  • grade in activity (grade of a student at an evaluative activety of a discipline offer)

The entity "student" should point to "person" (a student is alwais a person); the "discipline offer" has many "evaluative activities" and has many "students" (enrollment); and the "evaluative activity" has many "student grades".

In which entities you would link the entity "grade in activity"?

  1. link with "evaluative activity" and "person"
  2. link with "evaluative activity" and "student"
  3. link with "evaluative activity" and "enrollment"

Maybe, if you have took care about what I said, you have answered (c), that is the most appropriate in my opinion. But if you would be in front of this problem (without alternatives), would you bring the same answer?

The link between "grade" and "evaluative activity" is obvious. But the link between "grade" and "enrollment" is not often clear to see. It could be strange to link them, because "enrollment" does not look like a person, so, how it could get a grade? In fact, it is only a interpretation question about the entity. You can consider that "enrollment" is "a student that is enrolled in a discipline offer", and the "student" is a "person", so it could get a grade.

Yes, you could link the "grade" with the "student" or with the "person", but the database could be inconsistent, because it could exists a "grade" to a "student" in a "discipline offer" but the student is not enrolled at discipline offer. With the correct linking, you could only create a "grade" to a "student enrolled at a discipline offer" (in other words, a "enrollment"). To know which student gets the grade, you should get this data from the enrollment that points to the student.

In the end, modelling a database with precision is a work that should be done with atention and care, specially to define the propositions you consider true.

No comments:

Post a Comment