ENTITY RELATIONSHIP DIAGRAM
The ER model explains the overall view of a database. It works with real-world entities and associations among them. The ER model is considered as a best option for designing databases.
An entity can be a real-world object or a thing that can be identified easily.
Eg: If we consider a College Database, students, teachers, classes, and courses are. The entities have some attributes or properties that gives identification.
Entities are represented by their properties or characteristics called attributes. The attributes have values. For example, a student entity may have name, class, and age as attributes.
For every attribute a domain or range of values are assigned to attributes. For example, a student’s name cannot be a numeric value. It must be alphabetic. student’s age can’t be negative.
Types of Attributes
Simple attribute − Simple attributes are atomic in nature, which cannot be divided further. For example, mobile number is an atomic value of 10 digits.
Composite attribute − Composite attributes are composed of more than one simple attribute. For example, a student’s full name may have first_name and last_name.
Derived attribute − Derived attributes do not exist in the physical database, but their values are derived from other attributes present in the database. Eg: age can be derived from date of birth and the present date.
Single-value attribute − Single-value attributes contain single value. Eg: Employee is assigned with only single Empid.
Multi-value attribute − Multi-value attributes may contain more than one values. For example, a person can have more than one phone number, email_address, etc.
Primary Key − A primary key is a key or a single column chosen by the database designer to uniquely identify the rows of data in a table.
Relationship: We have 4 types of relationships.
One to One : Eg: A student will be associated with one student registration number during examination.
One to Many : Eg: A student will learn many subjects.
Many to Many : Eg: many students will learn many subjects in a class.
Many to One : Eg: Many subjects are taught by single faculty.