The Entity-Relationship model (ER model) is a conceptual model of data. As such it describes at high level the reality modeled regardless of how the data will be logically and physically represented.
The ER model defines a conceptual data schema. A schema describes the structure or form of the data, but does not describe the actual data, that is the instances or occurrences of the schema. For example, the ER schema may say that the plane entity has the manufacturer and model attributes but does not say what the actual values of these attributes are. Compared to object-oriented programming, the schema corresponds to the notion of class and an instance of the schema is an object of the class.
An ER schema contains the following components:
flies
among flights and planes associating each flight with the corresponding plane (or viceversa).Both entities and relationships can have atomic properties called attributes. Attributes can be obligatory (a value must be given) or optional (the value might not exist or be unknown). An attribute must have a unique name for the entity or relationship associated with.
A key of an entity is one or more attributes that identify unambiguously the instances of the entity. A key must be minimal (if we remove one the its attributes the key is no more unique) and all of its attributes must be obligatory.
Here, a plane has attributes manufacturer and model and is identified by key attribute tailnum.
We can distinguish three types of relationships in terms of participation cardinalities of its entities. The first type is a one-to-one relationship:
Here a kingdom is associated with zero or one instances of king and a king is associated with exactly one instance of kingdom. This relationship is in fact a possibly partial function.
The second type is a one-to-many relationship:
Here a flight is associated with exactly one instance of plane and a plane is associated with zero, one or more instances of flight.
The last type is a many-to-many relationship:
Here a student is associated with zero, one or more instances of course and a course is associated with one or more instances of student.
It is possible to have recursive relationships associating two equal entities: for instance, the relationship edge in a graph associates two entities node.
Notice the attribute weight on the relationship edge: this is a property of edges, which are pairs of nodes.