How to create references between class fields containing hyphens? how to define field alias?

0 votes
asked Sep 25, 2021 in Question / help by germo (160 points)

I have fields containing hyphens ('-') in class diagrams and I want to draw relations. But this doesn't work if the field name contains hyphens.

How I could do?
I could imagine to defining alias without hyphens for the field, but I don't know how.

Here I need to comment out the relations to a usable diagram

```

@startuml
left to right direction
'top to bottom direction
hide circle
'avoide "." issues:
set namespaceSeparator none

entity  DM.DimContact << U >> {
  - **DimContactID** : (nvarchar(100))
  --
  E-Mail : (nvarchar(80))
  Employee : (tinyint)
  Euler-Hermes-ID : (nvarchar(10))
  Fax_No_ : (nvarchar(30))
  First_Name : (nvarchar(30))
  --
  --
}

entity  DM.V_DimContact << V >> {
  --
  E-Mail : (nvarchar(80))
  Employee : (tinyint)
  Euler-Hermes-ID : (nvarchar(10)) as aaa_bbb_ccc
  Fax_No_ : (nvarchar(30))
  First_Name : (nvarchar(30))
  --
  --
}

'DM.DimContact::E-Mail <-- DM.V_DimContact::E-Mail
DM.DimContact::Employee <-- DM.V_DimContact::Employee
'DM.DimContact::Euler-Hermes-ID <-- DM.V_DimContact::Euler-Hermes-ID
DM.DimContact::Fax_No_ <-- DM.V_DimContact::Fax_No_
DM.DimContact::First_Name <-- DM.V_DimContact::First_Name
@enduml
```

btw, how to insert code here in the forum?

1 Answer

+1 vote
answered Sep 25, 2021 by The-Lu (64,760 points)

Hello G.,

Just put double quotes (") for those fields, like:

@startuml
left to right direction
'top to bottom direction
hide circle
'avoide "." issues:
set namespaceSeparator none

entity  DM.DimContact << U >> {
  - **DimContactID** : (nvarchar(100))
  --
  E-Mail : (nvarchar(80))
  Employee : (tinyint)
  Euler-Hermes-ID : (nvarchar(10))
  Fax_No_ : (nvarchar(30))
  First_Name : (nvarchar(30))
  --
  --
}

entity  DM.V_DimContact << V >> {
  --
  E-Mail : (nvarchar(80))
  Employee : (tinyint)
  Euler-Hermes-ID : (nvarchar(10)) as aaa_bbb_ccc
  Fax_No_ : (nvarchar(30))
  First_Name : (nvarchar(30))
  --
  --
}

"DM.DimContact::E-Mail" <-- "DM.V_DimContact::E-Mail"
DM.DimContact::Employee <-- DM.V_DimContact::Employee
"DM.DimContact::Euler-Hermes-ID" <-- "DM.V_DimContact::Euler-Hermes-ID"
DM.DimContact::Fax_No_ <-- DM.V_DimContact::Fax_No_
DM.DimContact::First_Name <-- DM.V_DimContact::First_Name
@enduml

If that can help,
Regards,
Th.

commented Sep 25, 2021 by germo (160 points)
Thank you very much! This works great!
...