Do digraphs not work with entities?

0 votes
asked Oct 4, 2018 in Question / help by chiarld (480 points)

My ultimate purpose is to be able to make entity-relationship diagrams. 

I would like to be able to establish relationships between entities using a diamond-shaped object.

First, I tried doing:

state c <<choice>>

PlantUML got mad saying I had to include "allow_mixing". After doing that, it seems to ignore the attribute "<<choice>>". 

After that, I tried using digraphs to draw a diamond and hopefully establish connections between them and entities.

So I tried:

digraph foo {
 " " [fillcolor=palegreen, style="filled", shape=diamond]
}

To get a clear diamond colored more or less like the classical PlantUML entity colors. This code works individually but when combined with entities I get "Syntax Error?"

In any case, I would really appreciate some help with this. 

I am currently taking a class in databases and we have to draw ER diagrams. I would much rather use your software (which is amazing btw) then "Astah UML", which is the one recommended by the professor. 

1 Answer

0 votes
answered Oct 4, 2018 by plantuml (294,960 points)
selected 5 days ago by chiarld
 
Best answer

Unfortunately, you cannot mix digraph and entities. Digraph is pure graphviz/dot diagram, which cannot be used with regular PlantUML diagram.

However, you can change the color of a diamond, using "skinparam activityBackgroundColor" (which is not very logical).

For example:

@startuml
skinparam backgroundColor LightYellow
skinparam state {
  StartColor MediumBlue
  EndColor Red
  BackgroundColor Peru
  BackgroundColor<<Warning>> Olive
  BackgroundColor<<choice>> palegreen
  BorderColor Grey
  FontName Impact
}
skinparam activityBackgroundColor palegreen

state "Req(Id)" as ReqId <<sdlreceive>>
state "Minor(Id)" as MinorId <<sdlsend>>
state "MinorReq := Id;" as MinorReq <<rect>>
state "Major(Id)" as MajorId <<sdlsend>>
state "MajorReq := Id;" as MajorReq <<rect>>
 
state c <<choice>>
 
Idle --> ReqId
ReqId --> c
c --> MinorId : [Id <= 10]
MinorId --> MinorReq
c --> MajorId : [Id > 10]
MajorId --> MajorReq
MinorReq --> j
MajorReq --> j
j --> Busy
@enduml

http://www.plantuml.com/plantuml/uml/RP11Jy8m68Rl_HLVEEc1HAyu5e9HiqJKuC4Ouw6sNqP7rsBNOOZnl_kLkjfCJ-LzUVhGbqNdkVDzgrctLMR77M_XZOjjxMnlvANLri6jgZV-6RMs7nb55pt29mDu38g8hb2glbtg7gc_6WHhb1IN8-q3klvlNHHFt1bbwhA4Uwts-1yYDbO996B7DTOEqGJAEeakkcyS7gYwjiRVyHQXQdTSUFQLlP-osYj_6Cap9OiJ9sjyFwdawGHu1_Ivab0KdTGE1TBxodBWLifObyXZ6jWEZHo1P8BP72fvaV3G4KzYdy6yoQsKnjOS75k7BbdX1nUG_iPGLb8ZJATb7CZYp9054-5CSsRm4dv-3kTdhsme4q3t1fut6Lz6F7R3zn5FmqFRHEOtDiTpsNS7jg2rVQk_0G00

Hope this help!

commented Oct 4, 2018 by chiarld (480 points)
Hey! Thanks for the quick reply!

I am able to make diamond shapes using state <<choice>> but I cannot mix them with entities. It asks me to "allowmixing" and, once I do, "state <<choice>>" stops being diamond shaped.

This is the code I currrently have:

entity   Student
{
  {field} id {PK}
  {field} name
  {field} sex
  {field} birthDate
  {field} GPA
}

entity   Professor
{
  {field} name
}

entity   Department
{
  {field} courses
  {field} professors
  {field} name
  {field} building location
}

entity   Course
{
  {field} name {PK}
  {field} number
}

entity   Section
{
  {field} professor
  {field} number
}

entity   EnrollsIn
{
  {field} grade
}

Section - Professor : Has >
Professor -- Department : IsIn >
Department - Course : Offers >
Course -- Section : From >
(Student, Section) .. EnrollsIn

All I want to do is be able to make a diamond shaped object and connect multiple entities to it.  I also thought about doing it using "if and else" but that doesn't seem to work with entities as well.
commented Oct 4, 2018 by plantuml (294,960 points)
Well, this is not possible with current version.
However, in last beta http://beta.plantuml.net/plantuml.jar we have added a new "diamond" keyword so that you can have :

@startuml
entity   Student {
  {field} id {PK}
  {field} name
  {field} sex
  {field} birthDate
  {field} GPA
}

entity   Professor {
  {field} name
}

entity   Department {
  {field} courses
  {field} professors
  {field} name
  {field} building location
}

entity   Course {
  {field} name {PK}
  {field} number
}

entity   Section {
  {field} professor
  {field} number
}

entity   EnrollsIn {
  {field} grade
}

Section - Professor : Has >
Professor -- Department : IsIn >
Department - Course : Offers >
Course -- Section : From >
(Student, Section) .. EnrollsIn

diamond diamond1

EnrollsIn -> diamond1
diamond1 --> Section : demo 1
diamond1 --> Department : another link
@enduml

Is this what you are looking for ?
commented Oct 4, 2018 by chiarld (480 points)
Woah! That is exactly what I wanted! Works like a charm. Thank you so so much!
...