Search code examples
database-designentity-relationshiperdcardinality

Which Cardinality would be applicable in a scenario described herein


I am trying to understand the Crow's foot notation for database design (ER diagram). I want to create an ER diagram for a scenario in which a STUDENT (entity/table) can enroll in multiple courses ( COURSES_ENROLLED table/entity).

I have created the following ER diagram.

enter image description here

Now, for this scenario which "connector symbol" would be applicable, the one marked with (1) or (2) ? Any explanation would be of great help.


Solution

  • I assume that you also have an entity COURSE (because you have courseId as a foreign key in COURSES_ENROLLED). So COURSES_ENROLLED links exactly one student to exactly one course enrolled by that student, right?

    This is expressed by alternative (1) in your diagram. Each COURSES_ENROLLED instance sees exactly one STUDENT instance, whereas each student can see many instances the other way round.

    Your alternative (2) would be appropriate if you did without the intermediate entity and directly linked STUDENT to COURSE. Between those, the multiplicity would be m:n, so you would have a crow's foot at both ends. But then courseId would be primary key of the right entity, and it should be called COURSE.

    By the way, check whether your constraint that is expressed both in (1) and (2), that a student must enrol at least one course, is realistic with respect to your functional requirements. Probably, each student will enrol at least one course at some point in time, but if you include this as a constraint in your data model, it will need to hold all the time. So your present model doesn't allow just to create a student without linking her to at least one course at once.