ER Model – Entities, Attributes, Relationships
1. What is the ER Model?
- Definition:
The Entity-Relationship (ER) Model is a conceptual database model that describes data as entities, attributes, and relationships.
- Purpose:
To visually represent data and how it is related. It’s a blueprint for database design.
2. Elements of the ER Model
A. Entities
- Definition:
Objects or things in the real world that can be distinctly identified.
Example: A “Student,” “Employee,” or “Product.”
- Types:
- Strong Entities:
- Exist independently.
- Have a primary key to uniquely identify them.
- Example: A “Book” in a library.
- Weak Entities:
- Depend on a strong entity for existence.
- Identified using a foreign key and a partial key.
- Example: “Dependent” entity in an Employee-Dependent relationship.
- Representation in ER Diagram:
- Rectangle for entities.
- Double rectangle for weak entities.
B. Attributes
- Definition:
Properties or characteristics of an entity or a relationship.
Example: “Name” and “Age” of a Student.
- Types:
- Simple Attributes: Cannot be divided further.
- Composite Attributes: Can be split into smaller sub-parts.
- Example: “Full Name” (can be divided into First Name and Last Name).
- Derived Attributes: Calculated from other attributes.
- Example: “Age” (calculated from Date of Birth).
- Multivalued Attributes: Can have multiple values for a single entity.
- Example: “Phone Numbers” of a person.
- Representation in ER Diagram:
- Oval for attributes.
- Dashed oval for derived attributes.
- Double oval for multivalued attributes.
C. Relationships
- Definition:
Links between two or more entities that show how they are related.
Example: “A Student ENROLLS in a Course.”
- Types of Relationships:
- One-to-One (1:1):
- One entity is related to only one other entity.
- Example: A passport is issued to one person.
- One-to-Many (1:N):
- One entity is related to multiple entities.
- Example: One teacher teaches many students.
- Many-to-Many (M:N):
- Many entities are related to many entities.
- Example: Students enroll in many courses, and courses have many students.
- Cardinality: Specifies the number of occurrences of entities in a relationship.
Example: “1:N”, “M:N”.
- Representation in ER Diagram:
- Diamond for relationships.
- Connect entities with lines and indicate cardinality.
3. Special Concepts in the ER Model
- Key Attribute:
- An attribute that uniquely identifies an entity.
- Example: “Student ID” for a Student entity.
- Generalization:
- Combining similar entities into a single higher-level entity.
- Example: “Car” and “Truck” can be generalized into “Vehicle.”
- Specialization:
- Dividing a higher-level entity into more specific lower-level entities.
- Example: “Employee” can be specialized into “Manager” and “Engineer.”
- Aggregation:
- A higher-level relationship involving relationships and entities.
- Example: A “Project” is assigned to an “Employee” by a “Manager.”
4. How to Draw an ER Diagram?
- Identify entities (nouns in the problem statement).
- Identify attributes for each entity.
- Identify relationships between entities.
- Determine cardinality of relationships.
- Draw the ER Diagram with proper symbols:
- Rectangles for entities.
- Diamonds for relationships.
- Ovals for attributes.
5. Quick Examples
- Banking System:
- Entities: Customer, Account, Transaction.
- Attributes: Name, Account No, Amount.
- Relationships: Customer HAS Account, Account PERFORMS Transaction.
- University Database:
- Entities: Student, Course, Instructor.
- Attributes: Name, ID, Credits, Salary.
- Relationships: Student ENROLLS in Course, Instructor TEACHES Course.
6. Last-Minute Learning Tips
- Mnemonic for the 3 elements:
- EAR = Entities, Attributes, Relationships.
- Symbols:
- Rectangle = Entity, Oval = Attribute, Diamond = Relationship.
- Focus on Key Terms: Strong/Weak entities, Multivalued/Derived attributes, Cardinality.
- Practice drawing small ER diagrams for simple systems (e.g., library, bank).
MCQ
Topic 1: Entities
- What is an entity in the ER Model?
A. A relationship between attributes
B. A uniquely identifiable object in the real world
C. A derived property of an attribute
D. A type of database query
Answer: B
- Which of the following is an example of a weak entity?
A. Book
B. Order
C. Dependent
D. Product
Answer: C
- What is used to uniquely identify a strong entity?
A. Foreign key
B. Composite key
C. Primary key
D. Derived attribute
Answer: C
- In an ER diagram, how is a weak entity represented?
A. Rectangle
B. Double rectangle
C. Oval
D. Diamond
Answer: B
- Which of the following statements is true about weak entities?
A. They can exist independently.
B. They require a foreign key to identify them.
C. They do not participate in relationships.
D. They are represented by a diamond in ER diagrams.
Answer: B
Topic 2: Attributes
- What is a multivalued attribute?
A. An attribute that is derived from other attributes
B. An attribute with multiple sub-parts
C. An attribute with multiple values for a single entity
D. An attribute that acts as a foreign key
Answer: C
- Which attribute type can be divided into smaller sub-parts?
A. Simple attribute
B. Composite attribute
C. Multivalued attribute
D. Derived attribute
Answer: B
- Which of the following is a derived attribute?
A. Name
B. Age (calculated from Date of Birth)
C. Phone Number
D. Employee ID
Answer: B
- In an ER diagram, how is a multivalued attribute represented?
A. Rectangle
B. Oval
C. Dashed oval
D. Double oval
Answer: D
- What is a key attribute in an entity?
A. An attribute that holds multiple values
B. An attribute used to uniquely identify an entity
C. An attribute derived from other attributes
D. An attribute that is not stored directly
Answer: B
Topic 3: Relationships
- What is a relationship in an ER Model?
A. A connection between entities
B. A type of attribute
C. A derived entity
D. A duplicate record in a database
Answer: A
- What type of relationship exists when one entity is associated with multiple entities of another type?
A. One-to-One
B. Many-to-Many
C. One-to-Many
D. Recursive
Answer: C
- How is a relationship represented in an ER diagram?
A. Rectangle
B. Oval
C. Diamond
D. Double diamond
Answer: C
- In the relationship “Employee WORKS_FOR Department”, which is the relationship?
A. Employee
B. WORKS_FOR
C. Department
D. Both Employee and Department
Answer: B
- What is the term for the number of entities involved in a relationship?
A. Degree
B. Cardinality
C. Multiplicity
D. Participation
Answer: A
- What does cardinality specify in a relationship?
A. The type of entities involved
B. The number of entities participating in the relationship
C. The attributes of the relationship
D. The type of attributes involved
Answer: B
- Which of the following is a Many-to-Many relationship?
A. A student can enroll in multiple courses, and each course can have multiple students.
B. A student has one ID card, and one ID card belongs to one student.
C. An employee works in one department, and one department has many employees.
D. A product has a unique barcode.
Answer: A
Topic 4: Special Concepts
- What is generalization in the ER Model?
A. Combining multiple entities into a higher-level entity
B. Dividing an entity into lower-level entities
C. A type of weak entity
D. A type of relationship
Answer: A
- Which of the following is an example of specialization?
A. “Vehicle” split into “Car” and “Truck”
B. “Employee” combined with “Manager”
C. “Course” related to “Student”
D. “Book” generalized into “Item”
Answer: A
- What is aggregation in the ER Model?
A. A relationship involving another relationship
B. A higher-level entity combining multiple attributes
C. A derived relationship between two entities
D. A multivalued attribute
Answer: A
Topic 5: Practical Applications
- In a university database, what could be entities and relationships?
A. Entities: Student, Course; Relationships: ENROLLS_IN
B. Entities: ENROLLS_IN; Relationships: Student, Course
C. Entities: Marks, Grade; Relationships: Student, Teacher
D. Entities: Student; Relationships: Attributes
Answer: A
- Which is true about the ER Model?
A. It represents data in tables only.
B. It describes data with entities, attributes, and relationships.
C. It focuses on physical storage of data.
D. It cannot model real-world scenarios.
Answer: B
- In a hospital database, what is the best representation of a “Patient undergoes Treatment”?
A. Patient is an attribute of Treatment.
B. Treatment is a weak entity related to Patient.
C. Patient and Treatment are unrelated entities.
D. Treatment is a derived attribute of Patient.
Answer: B