plantuml / plantuml

Generate diagrams from textual description
https://plantuml.com
Other
10.65k stars 975 forks source link

Chen Notation for ER-diagrams #945

Open HeroGamers opened 2 years ago

HeroGamers commented 2 years ago

I looked around for quite a while, and tried to see if anyone had made it possible to use the Chen notation in PlantUML yet, and I could only find the old Issue for the Crow's Foot notation (#39), yet no apparent implementation for the Chen notation, which is what I'm being taught in university, and which seems to be used widely (though it might be an older notation..?)

I'd definitely appreciate having the notation added to PlantUML, and I bet it would be great for others as well!

Some references: https://vertabelo.com/blog/chen-erd-notation/ https://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#/media/File:ERD_Representation.svg Chapter 6 of Database System Concepts (https://www.db-book.com/)

ahorn42 commented 2 years ago

I really like this this idea!

There was already a suggestion here: https://github.com/plantuml/plantuml/issues/39#issuecomment-474405783

PaienNate commented 1 year ago

Really like this idea too.

Benjamin-Davies commented 1 year ago

I've started work on an implementation for this. It's mostly done, I just need to change the shape of the relationships and tweak how the layout is done. https://github.com/Benjamin-Davies/plantuml/tree/cheneer

It would be good to get some feedback on the syntax.

@startchen movies

entity DIRECTOR {
  key attribute Number
  attr Name {
    Fname
    attribute Lname
  }
  attribute Born
  attribute Died
  attribute Age
}

entity CUSTOMER {
  key attribute Number
  derived attribute Bonus
  multi attribute Name
}

entity DVD {
  key attribute Code
}

relationship RENTED_TO {
  -1 CUSTOMER
  -N DVD

  -(N,M) DIRECTOR

  attribute Date
}

@endchen
The-Lum commented 1 year ago

@Benjamin-Davies:

Here are some first questions, for the syntax point of view:

Regards, Th.

HeroGamers commented 1 year ago

@Benjamin-Davies

Looks nice - I do have some feedback/questions for the syntax:

But otherwise great work!

Best regards, Marcus

Benjamin-Davies commented 1 year ago
  • Just for my comprehension, what is the meaning of the first E, on Chen EER?

The first E in EER stands for enhanced or extended (see Wikipedia). All ER diagrams are also EER diagrams, but EER adds support for subclassing of entities.

All of your suggestions look good. I'll probably end up dropping the "attribute" keyword and moving "key" etc. to be stereotypes, for consistency with other PlantUML diagram types.

hinogi commented 7 months ago

So what is the actual syntax now?

hinogi commented 7 months ago
@startchen movies
<style>
.red {
  BackGroundColor Red
  FontColor White
}
.blue {
  BackGroundColor Blue
  FontColor White
}
</style>

entity "Director" as DIRECTOR {
  "No." as Number <<key>>
  Name {
    Fname
    Lname
  }
  Born : DATE
  Died<<red>>
  Age<<blue>>
}

entity "Customer" as CUSTOMER {
  Number <<key>>
  Bonus <<derived>>
  Name <<multi>>
}

entity "Movie" as MOVIE {
  Code
}

relationship "was-rented-to" as RENTED_TO {
  Date
}

RENTED_TO -1- CUSTOMER
RENTED_TO -N- MOVIE
RENTED_TO -(N,M)- DIRECTOR

entity "Parent" as PARENT {
}

entity "Member" as MEMBER {
}

CUSTOMER ->- PARENT
MEMBER -<- CUSTOMER

entity "Kid" as CHILD <<weak>> {
  Name <<key>>
}

relationship "is-parent-of" as PARENT_OF <<identifying>> {
}

PARENT_OF -1- PARENT
PARENT_OF =N= CHILD

entity "Little Kid" as TODDLER {
  FavoriteToy
}

entity "Primary-Aged Kid" as PRIMARY_AGE {
  FavoriteColor
}

entity "Teenager" as TEEN {
  Hobby
}

CHILD =>= d { TODDLER, PRIMARY_AGE, TEEN }

entity "Human" as PERSON {
}

PERSON ->- U { CUSTOMER, DIRECTOR }
@endchen

ok found it in the implementation added some spacing and color examples

The-Lum commented 7 months ago

Hi all,

Here is the corresponding image:

Doc. can be improve here:

Thanks for your contributing... Regards, Th.

VladimirAlexiev commented 7 months ago

@The-Lum I fixed links between ER and IE, and added a last section "Complex Example" with the above example