Book a Demo

Author Topic: Doubt about constraints  (Read 4256 times)

zyx

  • EA User
  • **
  • Posts: 95
  • Karma: +1/-1
    • View Profile
Doubt about constraints
« on: January 05, 2024, 04:53:24 pm »
Hello all,

   Is there any constraint that can be applied to two attributes stating that is not mandatory both be fullfilled?

wdagressive

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Doubt about constraints
« Reply #1 on: January 08, 2024, 07:05:01 pm »
Hello all,

   Is there any constraint that can be applied to two attributes stating that is not mandatory both be fullfilled?
Hi,
you can express a constraint in a way that indicates that it's not mandatory for both attributes to be fulfilled. This is often referred to as a "soft" constraint or a "partial" constraint. In a database context, you might handle this through a combination of NULL values and constraints. For example, let's consider a table with two attributes: Attribute1 and Attribute2. You want to express that either Attribute1 or Attribute2 can have values, but not necessarily both.

zyx

  • EA User
  • **
  • Posts: 95
  • Karma: +1/-1
    • View Profile
Re: Doubt about constraints
« Reply #2 on: January 09, 2024, 05:54:40 am »
Hello, thank you for your reply. Is it possible to represent it using attributes multiplicity? I mean defining [0..1] multiplicity in both attributes, meaning that an attribute can have none or one value.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Doubt about constraints
« Reply #3 on: January 09, 2024, 08:51:34 am »
The "UML" way to do it would be to add an OCL constraint to the owning type that uses the xor operator between the legal values of the two attributes.

There are probably many EA ways to do it, but I'd probably add a constraint on the diagram and link it to both attributes. Depending on your target audience I'd then either write something like what you already did or a formal constraint in OCL.