Mapping cardinality
The identifying property of a relationship is known as its cardinality. The cardinality of a relationship permits the database modeler to specify how examples of each entity associate to each other. There are three main kind of cardinality:
- One-to-One. A single instance of one entity is related with a single instance of another entity. This type of relationship is associatively uncommon; it is classically used when an entity can be classified into various subtypes.If One-to-One relationship is more complex than a simple One-to-One cardinality, the line is generally indicates in some way (such as with a dot) to denotes the cardinality.
Above example of a 1: 1 binary relationship type is manages, that relates a department entity to the employee who manages that department. This describes the constraints that an employee can manage only one department and that a department has only one manager.
- One-to-Many: An example of an entity known as the parent is related with zero or various instances of another entity called the child. An instance of this kind of relationship can be found through examining the teacher and class entities. A teacher should instruct zero or more classes during the course of a semester.
A One-to-Many relationship is drawn as a line among the entities included. The child end of the relationship classically has a dot.
Above instance, consider a relationship type works for among the two entity types Employee and department that relate each employee with the department the employee works_for. Every relationship instance in Works_for associates one employee entity and one department entity.
- Many-to-Many. Many instances of an entity are related with many instances of another entity. Let’s consider the enrollment relationship among a student and a class. A single student should be enrolled in many classes and a single class may enroll many students. The SQL Server’s implementation of the relational model does not straightly support Many-to-Many relationships to a third entity.
A many-to-many relationship is drawn as a line among the entities included. Both ends of the line have a dot.