Book a Demo

Author Topic: How to indicate if an attribute is required?  (Read 28854 times)

jbailey.spatialdna

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
How to indicate if an attribute is required?
« on: May 07, 2016, 04:17:00 am »
Is there a standard way to indicate if an UML attribute is required?

In the model that I'm working on, some of the string attributes on some elements are required to contain values. When documenting the model, I'd like to be able to indicate whether or not a value is required for each attribute.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to indicate if an attribute is required?
« Reply #1 on: May 07, 2016, 04:47:21 am »
The standard UML way is to set the multiplicity to 1..1

Geert

StefanPears

  • EA User
  • **
  • Posts: 119
  • Karma: +6/-0
  • Unwissenheit schützt vor Erkenntnis nicht
    • View Profile
Re: How to indicate if an attribute is required?
« Reply #2 on: May 10, 2016, 01:01:42 am »
Well, UML specification says:
<multiplicity-range> is the multiplicity range of the Property. If this term is omitted, it implies a multiplicity
of 1 (exactly one).

I would recommend to mark optional attributes with [0..1] and to regard the ones without multiplicity as mandatory. In a database an attribute marked with [0..1] may have the NULL value, which is not the same as an empty string. If you have additional rules, e.g. a minimum of 5 chars and the first char is between 'A' and 'Z' or like that, it is a good idea to create a datatype with an invariant constraint describing those rules.

jbailey.spatialdna

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: How to indicate if an attribute is required?
« Reply #3 on: May 10, 2016, 01:23:06 am »
Hi Geert and Stefan,

Thanks for your responses. Agreed that using the multiplicity of 0 or 1 is the correct way to do it in UML.

From a documentation perspective, then, I'd like to indicate using the words "Required" or "Optional" (or some similar) depending on the minimum multiplicity value. Is this something that could be accomplished via a custom script in the document template?

Thanks,

Jon.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to indicate if an attribute is required?
« Reply #4 on: May 10, 2016, 06:27:02 am »
Sure using an SQL fragment or Script fragment you can reword it the way you like.

Geert

jbailey.spatialdna

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: How to indicate if an attribute is required?
« Reply #5 on: May 12, 2016, 05:53:18 am »
Thanks, Geert.

Does EA support SQL CASE clauses? When I define the following SQL query:

Code: [Select]
SELECT
CASE
WHEN LowerBound = 0 THEN 'Optional'
ELSE 'Required' 
END AS Required
FROM t_attribute;

I get the following error:

DAO.QueryDef [3075]

Syntax error (missing operator) in query expression 'CASE
WHEN LowerBound = 0 THEN 'Optional'
ELSE 'Required' 
END'.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to indicate if an attribute is required?
« Reply #6 on: May 12, 2016, 07:31:28 am »
EA does some SQL-preprocessing and does not accept every SQL dialect. You can try the SQL in the SQL scratch pad of the find function. If is does not work there, you are probably out of luck.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: How to indicate if an attribute is required?
« Reply #7 on: May 12, 2016, 09:27:12 am »
I can't see anything that EA would have done to that.

Open %appdata%\Sparx Systems\EA\dberror.txt

It should tell you what sql was actually trying to be run.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to indicate if an attribute is required?
« Reply #8 on: May 12, 2016, 01:55:04 pm »
There is no CASE statement in Access.

Something like this will work on an .eap file

Code: [Select]
SELECT
IIF (LowerBound = '0', 'Optional' ,'Required') AS Required
FROM t_attribute

Geert

jbailey.spatialdna

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: How to indicate if an attribute is required?
« Reply #9 on: May 12, 2016, 11:36:03 pm »
Great! Thanks, Geert.

I didn't realize that EA was using Access in the back end.