Data Model is a conceptual representation of data structures, operations, and constraints that define how data is stored, organized, and manipulated in a database system.
Hierarchical Data Model - Tree Structure
| Advantages | Disadvantages |
|---|---|
| Simple and fast access | Rigid structure |
| Data integrity through hierarchy | No many-to-many relationships |
| Efficient for 1:N relationships | Data redundancy issues |
Network Data Model - Graph Structure
| Advantages | Disadvantages |
|---|---|
| Handles many-to-many relationships | Complex navigation |
| More flexible than hierarchical | Requires technical expertise |
| Better data access paths | Structural dependency |
Relational Data Model - Table Structure
Object-Oriented Data Model - Class Structure
| Data Model | Structure | Relationships | Best Use Case |
|---|---|---|---|
| Hierarchical | Tree | 1:N only | Simple, predictable data |
| Network | Graph | M:N allowed | Complex relationships |
| Relational | Tables | Keys & Joins | Most business applications |
| Object-Oriented | Objects | Inheritance & Composition | Complex data types |
The ER Model is a high-level conceptual data model that describes the structure of a database using entities, attributes, and relationships.
ER Model Basic Components
ER Model Basic Components
| Entity Type | Entity Examples | Primary Key | Sample Attributes |
|---|---|---|---|
| Student | John Doe, Jane Smith, Alex Johnson | Student_ID | Name, Age, Email, Phone, Address |
| Employee | Mike Wilson, Sarah Brown, David Lee | Employee_ID | Name, Salary, Department, Hire_Date |
| Course | Database Systems, Java Programming, Data Structures | Course_ID | Course_Name, Credits, Duration, Prerequisites |
| Department | Computer Science, Electrical Engineering, Mathematics | Dept_ID | Dept_Name, Location, Budget, Head_Name |
| Book | Introduction to Algorithms, Operating Systems Concepts | ISBN | Title, Author, Publisher, Price, Pages |
| Attribute Type | Entity: Student | Entity: Employee | Entity: Course |
|---|---|---|---|
| Simple | Student_ID, Name, Age | Employee_ID, Name, Salary | Course_ID, Course_Name, Credits |
| Composite | Address (Street, City, State, ZIP) | Address (Street, City, State, ZIP) | Schedule (Day, Time, Room) |
| Single-valued | Student_ID, Date_of_Birth | Employee_ID, Social_Security_Number | Course_ID, Max_Enrollment |
| Multi-valued | Phone_Numbers, Email_Addresses | Skills, Certifications | Prerequisites, Topics_Covered |
| Derived | Age (from Date_of_Birth), GPA | Years_of_Service, Age | Enrollment_Count, Average_Grade |
| Key | Student_ID | Employee_ID | Course_ID |
| Relationship | Entity 1 | Entity 2 | Cardinality | Real Example |
|---|---|---|---|---|
| Works_In | Employee | Department | N:1 | John works in Computer Science Dept
Jane works in Electrical Engineering Dept |
| Enrolls_In | Student | Course | M:N | Alice enrolls in Database Systems
Alice enrolls in Computer Networks Bob enrolls in Database Systems Bob enrolls in Computer Networks |
| Manages | Employee | Department | 1:1 | Dr. Smith manages CS Department |
| Teaches | Instructor | Course | 1:N | Prof. Johnson teaches 3 courses
Dr. Williams teaches 2 courses |
| Borrows | Student | Book | M:N | Students can borrow multiple books |
| Supervises | Employee | Employee | 1:N (Unary) | Manager supervises multiple employees |
| Student_ID | Name | Age | Phone | |
|---|---|---|---|---|
| S001 | John Doe | 20 | john@email.com | +1-555-0123 |
| S002 | Jane Smith | 19 | jane@email.com | +1-555-0124 |
| S003 | Alex Johnson | 21 | alex@email.com | +1-555-0125 |
| Employee_ID | Name | Salary | Department | Hire_Date |
|---|---|---|---|---|
| E001 | Mike Wilson | 75000 | Computer Science | 2020-01-15 |
| E002 | Sarah Brown | 85000 | Electrical Engineering | 2019-08-20 |
| E003 | David Lee | 90000 | Computer Science | 2018-03-10 |
| Course_ID | Course_Name | Credits | Instructor | Max_Enrollment |
|---|---|---|---|---|
| CS101 | Database Systems | 3 | Dr. Smith | 30 |
| CS102 | Java Programming | 4 | Prof. Johnson | 25 |
| CS103 | Data Structures | 3 | Dr. Williams | 35 |
| Student_ID | Course_ID | Enrollment_Date | Grade |
|---|---|---|---|
| S001 | CS101 | 2024-01-15 | A |
| S001 | CS102 | 2024-01-15 | B+ |
| S002 | CS101 | 2024-01-16 | A- |
| S003 | CS103 | 2024-01-17 | B |
Visual representation of the ER model using standardized symbols.
ER Diagram Symbols and Notation
| Symbol | Representation | Description |
|---|---|---|
| Rectangle | Entity | Strong entity set |
| Double Rectangle | Weak Entity | Weak entity set |
| Diamond | Relationship | Relationship set |
| Ellipse | Attribute | Simple attribute |
| Double Ellipse | Multi-valued | Multi-valued attribute |
| Dashed Ellipse | Derived | Derived attribute |
| Underlined | Key | Key attribute |
Cardinality defines the number of entity instances that can be associated with another entity instance through a relationship.
Different Types of Cardinality
| Cardinality Type | Description | Example |
|---|---|---|
| One-to-One (1:1) | Each entity in A relates to at most one entity in B | Person ↔ Passport |
| One-to-Many (1:N) | Each entity in A relates to many entities in B | Department → Employees |
| Many-to-One (N:1) | Many entities in A relate to one entity in B | Students → Course |
| Many-to-Many (M:N) | Many entities in A relate to many entities in B | Students ↔ Courses |
| Employee Table | ||
|---|---|---|
| Emp_ID | Name | Office_ID |
| E001 | John | O101 |
| E002 | Jane | O102 |
| E003 | Mike | O103 |
| Office Table | ||
|---|---|---|
| Office_ID | Room_No | Floor |
| O101 | 101 | 1st |
| O102 | 102 | 1st |
| O103 | 201 | 2nd |
Each employee has exactly one office, and each office is assigned to exactly one employee.
| Department Table | |
|---|---|
| Dept_ID | Dept_Name |
| D001 | Computer Science |
| D002 | Mathematics |
| Employee Table | ||
|---|---|---|
| Emp_ID | Name | Dept_ID |
| E001 | John | D001 |
| E002 | Jane | D001 |
| E003 | Mike | D002 |
| E004 | Sarah | D001 |
One department can have many employees, but each employee belongs to exactly one department.
| Student Table | |
|---|---|
| Stud_ID | Name |
| S001 | Alice |
| S002 | Bob |
| S003 | Charlie |
| Course Table | |
|---|---|
| Course_ID | Course_Name |
| C001 | Database |
| C002 | Java |
| C003 | Data Structures |
| Enrollment Table (Bridge Table) | |||
|---|---|---|---|
| Stud_ID | Course_ID | Semester | Grade |
| S001 | C001 | Fall 2024 | A |
| S001 | C002 | Fall 2024 | B+ |
| S002 | C001 | Fall 2024 | A- |
| S002 | C003 | Fall 2024 | B |
| S003 | C002 | Fall 2024 | A |
| S003 | C003 | Fall 2024 | B+ |
Many students can enroll in many courses. A bridge table is needed to represent this M:N relationship.
Participation defines whether all entities in an entity set must participate in a relationship.
Generalization and Specialization Example
Aggregation in ER Model
| Constraint | Description | Notation |
|---|---|---|
| Disjoint | Entity can belong to at most one subclass | d in circle |
| Overlapping | Entity can belong to multiple subclasses | o in circle |
| Total | Every entity must belong to at least one subclass | Double line |
| Partial | Some entities may not belong to any subclass | Single line |
Answer: Entity is a thing or object (like Student, Course), while Attribute is a property of an entity (like Name, Age of Student).
Answer:
Answer: Generalization is bottom-up (specific → general), Specialization is top-down (general → specific).
Answer: When you need to treat a relationship as an entity to form relationships with other entities.
Answer: Strong entity has its own primary key, weak entity depends on another entity for identification.
| Concept A | Concept B | Key Difference |
|---|---|---|
| Entity | Attribute | Entity is a thing, Attribute is a property |
| Strong Entity | Weak Entity | Strong has own key, Weak depends on others |
| Total Participation | Partial Participation | Total is mandatory, Partial is optional |
| Generalization | Specialization | Bottom-up vs Top-down approach |
| Model | Key Feature | Main Advantage | Main Disadvantage |
|---|---|---|---|
| Hierarchical | Tree Structure | Fast Access | Rigid Structure |
| Network | Graph Structure | Flexible Relationships | Complex Navigation |
| Relational | Table Structure | Simplicity & Flexibility | Performance Issues |
| Object-Oriented | Objects & Methods | Real-world Modeling | Complexity |