Definition
Cardinality is the uniqueness and relationship properties of data in databases. Expressed in 1:1, N:M, and 1:N, it indicates the number of occurrences of one entity that can be linked with similar cases of another database entity. Cardinality is essential as it enhances the integrity and consistency of data in the database.
This relationship also symbolizes the total instances of one entity linked with nothing, one, or several cases of a different entity in a database, such as 1:1 (one-to-one relationship), 1:N (one-to-many relationship), and N:M (many-to-many relationship).
Examples of Cardinality
- One-to-one (1:1): A relationship where one occurrence of an entity is linked with only one example of another entity. For instance, assigning one employee to one office location.
- Many-to-many (N:M): This is a relationship where one or more occurrences of an entity can be linked with one or more instances of a different entity. For example, learners can enroll in multiple courses, and each course may have several students. A junction or associative table is usually used to link the two entities to have a many-to-many relationship in a relational database.
- One-to-many (1:N): This describes a relationship in which a single instance of an entity connects to one or numerous instances of another entity. For example, one department can have several workers, but each staff can only belong to a single department.