Database Reference
In-Depth Information
Every relationship has a parent and a child. The parent entity appears on the one side of the
relationship, and the child appears on the many side of the relationship. In this example, the
parent entity is Author and the child entity is Title . When I read a relationship, I start with
the entity on the one side of the relationship (the parent entity) first. “Each Author may
write one or many Titles .” It's then followed by reading the relationship from the many
side: “Each Title must be written by one Author .”
I also always use the word each in reading a relationship, starting with the parent side. The
reason for the word each is that you want to specify, on average, how many instances of
one entity relate to an entity instance from the other entity.
Let's change the cardinality and now allow a Title to be written by more than one Author :
This is an example of a many-to-many relationship, in contrast to the previous example,
which was a one-to-many relationship. The business rules here read as follows:
Each Author may write one or many Titles .
Each Title must be written by one or many Authors .
Write, in both of our examples, is an example of a relationship label.
The three levels of granularity (conceptual, logical, and physical) that apply to entities
and attributes also apply to the relationships that connect entities. Conceptual relationships
are high level rules that connect key concepts. Logical relationships are detailed business
rules that enforce the rules between the logical entities. Physical relationships are detailed
technology-dependent rules between the physical structures that the relationship connects.
These physical relationships eventually become database constraints, which ensure that
data adheres to the rules. A “constraint” is a physical term for a relationship in an RDBMS,
similar to an entity becoming a table and an attribute becoming a column. MongoDB can
capture but not enforce relationships through referencing, or can combine entities togeth-
er (similar to denormalizing) through embedding. Referencing and embedding will be dis-
cussed shortly.
RECURSION
Search WWH ::




Custom Search