You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
An Entity-Relationship (E-R) Diagram is a visual representation of the entities in a database and the relationships between them. E-R diagrams are used during the design stage of database development to plan the structure before implementation.
An entity is a real-world object or concept about which data is stored. In an E-R diagram, entities are shown as rectangles.
Examples: Student, Course, Teacher, Order, Product.
Attributes are the data items stored about each entity. They are shown as ovals connected to their entity (in Chen notation) or listed inside the entity box (in Crow's Foot notation).
Examples for a Student entity: StudentID, FirstName, Surname, DateOfBirth.
Key attribute: The primary key is usually underlined.
Relationships show how entities are connected. They are shown as diamonds in Chen notation or as lines in Crow's Foot notation.
Examples: Student enrols on Course, Teacher teaches Course.
Cardinality describes the number of instances of one entity that can be associated with instances of another.
| Cardinality | Meaning | Notation |
|---|---|---|
| 1:1 | One-to-one | One instance of A relates to exactly one instance of B |
| 1:M | One-to-many | One instance of A relates to many instances of B |
| M:M | Many-to-many | Many instances of A relate to many instances of B |
This is the most commonly used notation at A-Level. The symbols at each end of a relationship line indicate cardinality:
Example: A Department has many Teachers.
Department ||------|< Teacher
Reading this: one Department has many Teachers. Each Teacher belongs to exactly one Department.
Read the scenario carefully and identify the main objects or concepts. Look for nouns:
"A library lends books to members. Each book has an author."
Entities: Library, Book, Member, Author.
Look for verbs that connect entities:
Ask: "How many of entity A relate to how many of entity B?"
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.