Internal Uniqueness Constraints — Object-Role Modeling
By: Victor Morgante
Tags: Object Role Modeling, Uniqueness Constraint, Conceptual Modelling, Editors Pick, Internal Uniqueness

Internal Uniqueness Constraints — Object-Role Modeling

Internal Uniqueness Constraints made easy

Object-Role Modeling (ORM) is a graphical conceptual modelling technique used predominantly for database analysis and design, but used for any circumstance where you would like to document or define a data structure.

The following is a typical Object-Role Model:

An Object-Role Model. Image by author.

The model above depicts a data structure designed to store information about items in a shop that have been ordered by customers, in a quantity and on a date.

Object-Role Models use Fact Types to define the roles played by ostensible objects in relation to the Facts that the fact types describe. For instance, the fact, “Order 1 was made on Date 2020–12–15” conforms to the Fact Type pictorially described as:

A Fact Type in Object-Role Modeling. Image by author.

Internal Uniqueness Constraints in ORM

The horizontal purple bar within the fact type (above) is an Internal Uniqueness Constraint. Because it is on the role played by Order, each occurrence of an Order Nr (e.g. 1) within the fact type may occur exactly once. That is, each occurrence of Order Nr within the fact type is unique.

Internal uniqueness constraints can also be read as defining relative cardinality, as in a date can have many orders, but each order has only one date. That is, the relationship is a many-to-one relationship.

If each order in our Universe of Discourse can be made on only one date, and each date can have only one order, we can use internal uniqueness constraints to define this one-to-one relationship, as follows:

A one-to-one relationship using Internal Uniqueness Constrains in Object-Role Modelling. Image by author.

A many-to-many relationship can be established where the internal uniqueness constraint spans more than one role, as follows:

An Internal Uniqueness Constraint spanning more than one role. Image by author.

The internal uniqueness constraint spanning the roles played by Order and Item in the fact type, OrderItem, means that any one Order can have many Items, and each Item can be included in more than one Order; each combination of Order_Nr and Item_Nr is unique.

NB When the horizontal internal uniqueness constraint bar is represented by a double line (as above), this means that the uniqueness constraint represents the preferred reference scheme for the corresponding conceptual object; in this case, OrderItem.

NB In each case we have investigated, note that the bar of the internal uniqueness constraint spans at least n minus one roles of the corresponding fact type, where n is the number of roles in the fact type. For instance, the following two diagrams say the same thing structurally:

Internal Uniqueness Constraint spanning n minus one roles. Image by author.

Equivalent Object-Role Model. Image by author.

Preferred Reference Scheme

In Object-Role Modeling, when an Entity Type, such as Order, has a bracketed Reference Mode, as in (.Nr) for Order, this is known as the Preferred Reference Scheme for the Entity Type. This means that Order_Nr (the extrapolated name for the Value Type for the reference scheme) for each Order is unique.

This can be confusing to the uninitiated, and is best exemplified by expanding the reference scheme so that we can see what is going on:

An expanded reference scheme for the Order Entity Type. Image by author.

Expanded, it is easy to see that each order has a one-to-one relationship with the corresponding Order_Nr, and the double-bar internal uniqueness constraint on the role joining Order_Nr indicates that this is the Preferred Reference Scheme for the Order Entity Type.

For those familiar with Entity-Relationship Diagrams for Relational Databases, this is the equivalent of saying that Order_Nr is the primary key for the entity, Order; as follows:

Entity Relationship Diagram. Image by author.

Summary

Internal Uniqueness Constraints in Object-Role Modeling are represented by purple bars that span the roles over which the uniqueness constraint applies. When the bar is doubled it indicates that the internal uniqueness constraint represents the preferred reference scheme for the corresponding conceptual object, and each internal uniqueness constraint spans at least n minus one roles, where n is the number of roles in the corresponding fact type.

I hope this has been helpful in understanding internal uniqueness constraints in Object-Role Modeling. In a future article I will examine External Uniqueness Constraints in ORM, and where they are useful in constraining the model.

Thank you for reading, as time permits I will write more on Object-Role Modeling and conceptual modelling.

— — — — — — — — — — — — — — — — — — — — — — -