Skip to main content
Version: 3.8

Unique Constraints in R-COM Gateway

A Unique Constraint is a validation rule that prevents duplicate records from being created based on one or more selected attributes.

In an Object Group, each Object represents a record. A unique constraint defines which attribute value, or combination of attribute values, must be unique across all Objects in that group. This helps maintain clean and reliable data by ensuring that the same entity is not added multiple times.

For example, if an Object Group stores employee records, the employee_id attribute can be configured as a unique constraint. This means no two employee records can have the same employee ID.

Why Unique Constraints Are Used​

Unique constraints are used to prevent duplicate data and enforce business rules.

They are useful when certain values must identify a record uniquely, such as:

Example AttributeReason for Uniqueness
employee_idEach employee should have only one employee ID.
serial_numberEach device should have a unique serial number.
product_codeEach product should have one unique product code.
asset_tagEach tracked asset should have a unique asset tag.

Without unique constraints, users or workflows may accidentally create duplicate Objects with the same identifying information. This can cause incorrect reports, duplicate workflow actions, tracking errors, or inconsistent data.

Single-Attribute Unique Constraint​

A single-attribute unique constraint checks one attribute.

Example

ConstraintRule
serial_numberNo two Objects can have the same serial number.

Existing Object

{
"serial_number": "SN-10001",
"name": "Scanner A"
}

New Object

{
"serial_number": "SN-10001",
"name": "Scanner B"
}

Result

  • Rejected

Reason

  • The serial_number value already exists.

Multi-Attribute Unique Constraint​

A unique constraint can also use multiple attributes. In this case, the combination of values must be unique.

Example

ConstraintRule
name + DOBNo two Objects can have the same name and date of birth combination.

Existing Object

{
"name": "John Smith",
"DOB": "1990-04-15"
}

New Object

{
"name": "John Smith",
"DOB": "1990-04-15"
}

Result

  • Rejected

Reason

  • The same combination of name and DOB already exists.

However, the following Object would be accepted:

{
"name": "John Smith",
"DOB": "1988-09-10"
}

Reason

  • The complete combination is different.

How Unique Constraint Validation Works​

When a new Object is added to an Object Group, R-COM Gateway checks it against all configured unique constraints.

The Object is created only if all unique constraints pass.

If any constraint fails, the Object is not created because it would violate a uniqueness rule.

For a constraint to be valid during validation, at least one attribute in that constraint must contain a value. If all attributes in a constraint are empty, the constraint cannot pass.

Example​

Consider an Object Group used to store medical equipment.

Configured unique constraints:

ConstraintPurpose
equipment_idEnsures each equipment has a unique internal ID.
serial_numberEnsures each physical device is registered only once.
name + locationPrevents duplicate equipment records with the same name in the same location.

When a user adds a new equipment Object, the system checks all three constraints.

  • If the equipment_id already exists, the Object is rejected.
  • If the serial_number already exists, the Object is rejected.
  • If the name and location combination already exists, the Object is rejected.

Summary​

A Unique Constraint ensures that specific attribute values, or combinations of values, remain unique within an Object Group. It helps prevent duplicate Objects, improves data quality, and enforces important business rules.

Use unique constraints for attributes that identify an Object, such as:

  • employee_id
  • serial_number
  • product_code
  • asset_tag
  • Other values that should not be repeated