Before writing a single line of SQL, database engineers design the database logically using the Entity-Relationship (ER) Model. It is a high-level conceptual data model developed by Peter Chen in 1976 to facilitate database design by allowing specification of an enterprise schema that represents the overall logical structure of a database.
The ER model is typically visualized using an ER Diagram (ERD).
The ER Model is built upon three basic concepts: Entities, Attributes, and Relationships.
An Entity is a "thing" or "object" in the real world that is distinguishable from all other objects.
Students in a university).Entities are described by Attributes.
Student entity may have attributes ID, Name, Age, and Address.Types of Attributes:
Age).Name can be divided into FirstName and LastName).Phone_Numbers - a person can have multiple). Represented by Double Ovals.Age can be derived from Date_of_Birth). Represented by Dashed Ovals.A Relationship is an association among several entities.
Student enrolls in a Course.Mapping cardinalities (or cardinality ratios) express the number of entities to which another entity can be associated via a relationship set. This is crucial for determining how tables will be created in SQL.
Citizen has Passport.Department employs Instructors. (A department has many instructors, but an instructor works for exactly one department).Student takes Course. (A student takes many courses, and a course has many students).An entity set may not have sufficient attributes to form a primary key. Such an entity set is termed a Weak Entity Set.