Database Reference
In-Depth Information
On the model in Example 1, we see that Account Number is unique, and therefore to re-
trieve a specific Account requires only knowing the Account Number and not anything
from Customer , making Account an independent entity because Account Number be-
longs to Account . However, in Example 2, Account Number 34 appears three times, so
the only way to find a specific account is to know who the customer is. So the combina-
tion of Customer ID and Account Number is required to distinguish a particular account,
making Account in Example 2 a dependent entity because Customer ID , which is needed
to help identify accounts, does not belong to Account .
Notice also that the relationship line looks different when connecting to an independent
verses dependent entity. The dotted line means non-identifying and the solid line means
identifying . Identifying relationships mean that the entity on the many side (the child) is
always going to be a dependent entity (like Account in Example 2) to the entity on the one
side (the parent).
If we are designing a MongoDB database and trying to decide whether we should embed
documents or reference other documents, a major factor would be whether the relationship
is identifying or non-identifying. An identifying relationship is a much stronger relation-
ship than non-identifying, giving us more weight towards embedding the weak entity with-
in the strong entity so that we have just one document.
1 There is a one-to-one relationship between two entities . A one-to-one relation-
ship means that for a given entity instance, there can be at most one entity in-
stance relating to it, meaning if we decide to embed, there will be no redund-
Search WWH ::




Custom Search