Basics of ERD
- D A Rosi A. W.
- Jun 15
- 1 min read
Definition
Before we delve into entity relationship diagrams, or ERDs, we need to understand what an entity and its relationships are. Let's start with the entity: an entity is a real-world object or concept that can be distinctly identified and described by attributes. Meanwhile, an attribute is a characteristic associated with the entity. Entities are connected through relationships, and each relationship line has a cardinality. There are four types of cardinality in relationships: one-to-one, one-to-many, many-to-one, and many-to-many. Cardinality defines the extent to which data in one entity is related to another entity. For example, one or more students (entity) can attend (relationship) one or more classes (entity), indicating a many-to-many cardinality.
Making of Simple ERD
Let's create the diagram by adding attributes to each entities. A student is characterized by attributes such as studentID (PK), student_name, phone_number, and enrollment_year. A class is defined by attributes like classID (PK), room_name, course_schedule, semester, and academic_year. Both entities are independent and do not rely on each other for existence (strong entity). The "attends" relationship, which is many-to-many, includes attributes like attendanceID, attendance_date, attendance_status, and time_in. Because the 'attends' relationship has attributes, it is represented as an associative entity in the ERD, which includes foreign keys from the related entities. It is important to note that an associative entity occurs only in a many-to-many relationship, not in other types of relationships. Therefore, studentID and classID act as foreign keys (FK) within "attends". The final diagram would therefore look like this:


Comments