Difference Between Relationship Vs. Cardinality
- Cardinality limits the number of times a particular data piece can appear in relationship to another entity. For example, if you build a database to sort a person's contact information you might limit the number of addresses with cardinality. You could allow a name to be associated with only one address or with multiple addresses. Cardinality determines the limit of addresses a person could enter.
- Relationships in data mean many things. Connectivity is one type of relationship. Data relates to other data on a one-to-one basis, one to many basis or many to many. Depending on the type of information you have, you set up the relationship between the information. While this seems similar to cardinality, relationship limitations in connectivity do not limit the number of occurrences of particular data. Instead, you limit the number of relationships data has. For example, a name in a contact database can be associated with a number of different data values: phone number, address, city, state, etc. This represents a one to many relationship. The cardinality limits the number of addresses associated with a single name.
- Existence dependency is another relationship. This means you only have a value for one thing if you have a value for another. In organizing data this type of relationship allows you to verify you have all the necessary information. For example, you could make total time dependent on each lap time of a runner. If a runner fails to complete all the laps the total time comes up "N/A" or not applicable. This keeps the information comparable from record to record. Otherwise, a total time might look significantly less, ranking a runner higher, when really the person only completed three of the four laps.
- If-come relationships are similar to existence dependency relationships but offer options dependent on the data. This type of relationship has one piece of data that if one thing happens leads to another data point and if something else happens it goes to another point. These relationships allow for many possibilities and require a definition of what leads to what. Cardinality can be applied to this type of relationship by only allowing data to come up a certain number of times at each level of the relationship.