|
| 1 | +--- |
| 2 | +id: er-model-basics-concepts |
| 3 | +title: DBMS ER Model Basic Concepts |
| 4 | +sidebar_label: ER Model Basic Concepts |
| 5 | +sidebar_position: 1 |
| 6 | +description: Learn about the Entity-Relationship (ER) model, its basic concepts, entities, attributes, and relationships that form the foundation of database design. |
| 7 | +tags: |
| 8 | + - DBMS |
| 9 | + - ER Model |
| 10 | + - Database Design |
| 11 | +--- |
| 12 | + |
| 13 | +# DBMS - ER Model Basic Concepts |
| 14 | + |
| 15 | +The ER model defines the conceptual view of a database. It works around real-world entities and the associations among them. At view level, the ER model is considered a good option for designing databases. |
| 16 | + |
| 17 | +## Entity |
| 18 | + |
| 19 | +An entity can be a real-world object, either animate or inanimate, that can be easily identifiable. For example, in a school database, students, teachers, classes, and courses offered can be considered as entities. All these entities have some attributes or properties that give them their identity. |
| 20 | + |
| 21 | +An entity set is a collection of similar types of entities. An entity set may contain entities with attribute sharing similar values. For example, a Students set may contain all the students of a school; likewise, a Teachers set may contain all the teachers of a school from all faculties. Entity sets need not be disjoint. |
| 22 | + |
| 23 | +## Attributes |
| 24 | + |
| 25 | +Entities are represented by means of their properties, called attributes. All attributes have values. For example, a student entity may have name, class, and age as attributes. |
| 26 | + |
| 27 | +There exists a domain or range of values that can be assigned to attributes. For example, a student's name cannot be a numeric value. It has to be alphabetic. A student's age cannot be negative, etc. |
| 28 | + |
| 29 | +### Types of Attributes |
| 30 | + |
| 31 | +| Type | Description | |
| 32 | +| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 33 | +| Simple attribute | Atomic values, which cannot be divided further. Example: a student's phone number is an atomic value of 10 digits. | |
| 34 | +| Composite attribute | Made of more than one simple attribute. Example: a student's complete name may have first_name and last_name. | |
| 35 | +| Derived attribute | Attributes that do not exist in the physical database, but their values are derived from other attributes. Example: average_salary in a department. | |
| 36 | +| Single-value attribute | Contain a single value. Example: Social_Security_Number. | |
| 37 | +| Multi-value attribute | May contain more than one value. Example: a person can have more than one phone number, email_address, etc. | |
| 38 | + |
| 39 | +These attribute types can come together in a way like − |
| 40 | + |
| 41 | +- Simple single-valued attributes |
| 42 | +- Simple multi-valued attributes |
| 43 | +- Composite single-valued attributes |
| 44 | +- Composite multi-valued attributes |
| 45 | + |
| 46 | +## Entity-Set and Keys |
| 47 | + |
| 48 | +Key is an attribute or collection of attributes that uniquely identifies an entity among an entity set. |
| 49 | + |
| 50 | +For example, the roll_number of a student makes him/her identifiable among students. |
| 51 | + |
| 52 | +- **Super Key** − A set of attributes (one or more) that collectively identifies an entity in an entity set. |
| 53 | +- **Candidate Key** − A minimal super key is called a candidate key. An entity set may have more than one candidate key. |
| 54 | +- **Primary Key** − A primary key is one of the candidate keys chosen by the database designer to uniquely identify the entity set. |
| 55 | + |
| 56 | +## Relationship |
| 57 | + |
| 58 | +The association among entities is called a relationship. For example, an employee works_at a department, a student enrolls in a course. Here, Works_at and Enrolls are called relationships. |
| 59 | + |
| 60 | +### Relationship Set |
| 61 | + |
| 62 | +A set of relationships of similar type is called a relationship set. Like entities, a relationship too can have attributes. These attributes are called descriptive attributes. |
| 63 | + |
| 64 | +### Degree of Relationship |
| 65 | + |
| 66 | +The number of participating entities in a relationship defines the degree of the relationship. |
| 67 | + |
| 68 | +- Binary = degree 2 |
| 69 | +- Ternary = degree 3 |
| 70 | +- n-ary = degree n |
| 71 | + |
| 72 | +### Mapping Cardinalities |
| 73 | + |
| 74 | +Cardinality defines the number of entities in one entity set, which can be associated with the number of entities of another set via a relationship set. |
| 75 | + |
| 76 | +| Cardinality | Diagram | Description | |
| 77 | +| ------------ | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 78 | +| One-to-one |  | One entity from entity set A can be associated with at most one entity of entity set B and vice versa. | |
| 79 | +| One-to-many |  | One entity from entity set A can be associated with more than one entities of entity set B; however, an entity from entity set B can be associated with at most one entity. | |
| 80 | +| Many-to-one |  | More than one entities from entity set A can be associated with at most one entity of entity set B; however, an entity from entity set B can be associated with more than one entity from entity set A. | |
| 81 | +| Many-to-many |  | One entity from entity set A can be associated with more than one entity from entity set B and vice versa. | |
0 commit comments