One-To-One and N-To-One Relationships: How to Get Around Them

by Sarah Nimitz on April 25, 2017

“The record could not be deleted because of an association.”

This common error appears when a user attempts to delete a record, perhaps data they believe is unused or unnecessary. The vagueness of the error can lead to frustration for the user. What exactly does CRM mean by “an association?” Why does this prevent its deletion? And how can this issue be resolved so that the record can correctly be deleted?

In CRM, an association exists between two entities. Specifically, it is used to identify when records logically reference each other, whether for use by the system itself or by its users. Most commonly this exists as a lookup field on a record pointing to another.

A given record may have three different types of associations: 1:N, N:1, and N:N. The name signifies what direction the relationship is, where 1 is a single record and N represents an unknown and unlimited number of records. An N:1 relationship on an entity is usually the result of a lookup on that record type, since multiple records of that type can refer to the same record via the lookup. A record will have the opposite, a 1:N relationship, when the opposite is true and its record type is referred to on a lookup from another record.

These relationships are a result of how a database handles information. When you store information in a lookup, you are not storing a direct reference to the record; instead, you are storing where that record should be found. This is an important distinction, as knowledge of where the record should be does not guarantee that a record will be there, just as knowing someone’s address does not guarantee knowing where they are after they move.

For example, let’s say that a user creates a product that costs only ten dollars, used to cover the cost of going to a movie. The order that is generated only knows where that ten dollar product should be. Maybe down the line, another user deletes the ten dollar product and in its place creates a ninety dollar product to cover instead buying a piece of software. Since the order created earlier only knows where the product should be, and luckily finds a product there, it is suddenly a very expensive movie ticket. This situation is prevented in CRM by it preventing a user from deleting records referenced elsewhere by other records.

The final relationship, N:N or “many-to-many,” is also a symptom of this system of how databases store record information. When a record is created, it is created in the database with a finite number of fields, perhaps better visualized as a table with a finite number of columns. If a user wanted to create a record used to represent a class in a high school, with a relationship to every student in that class, they could try to create multiple fields — Student One, Student Two, Student Three, etc — but that is not the best way to go about it. What if a class is unusually large and has more students than fields had been created? Since high school students can be enrolled in multiple classes, we cannot use a lookup on the student record for that same reason. What if a student is enrolled in more classes than the user expected?

Microsoft CRM gets around this limitation for N:N relationships by treating it differently than simply a lookup. Instead, a completely new record type is generated for each of these relationships called an intersect entity. In the high school example, an intersect entity may be created called Enrollment. This Enrollment record will only consist of three fields; a unique identifier as all other records in CRM contain, a lookup to a student, and a lookup to a class.

Enrollment now has two N:1 relationships, one to student and one to class, which in turn creates the N:N relationship needed between class and student. This allows any number of students to be enrolled in any number of classes. In CRM, an individual intersect entity is created via a table on either one desired record or the other, visible on the form itself or available on the top navigation tiles.

So when an entity tells you it cannot be deleted because of an association, look through all possible relationships it can have. Is it referenced by a lookup on another record? Does it share an intersect entity with another record? Go through the list and ensure that all references to it have been deleted. A full list of possible associations can be found in the customizations of your organization, listed under the entity. Once all of these relationships have been deleted – or corrected to whatever record is replacing this one – your record should then be able to be deleted.

crm dynamics End-To-One Relationships One-To-One relationships