Skip to content

Instantly share code, notes, and snippets.

@QuantumGhost
Last active June 18, 2025 14:09
Show Gist options
  • Save QuantumGhost/0955a45383a0b6c0bc24f9654b3cb561 to your computer and use it in GitHub Desktop.
Save QuantumGhost/0955a45383a0b6c0bc24f9654b3cb561 to your computer and use it in GitHub Desktop.

Revisions

  1. QuantumGhost revised this gist Oct 10, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion example.puml
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@ not_null(password) VARCHAR[64]
    Table(session, "session\n(session for user)") {
    primary_key(id) INTEGER
    not_null(user_id) INTEGER
    not_null(unique(session_id) VARCHAR[64]
    not_null(unique(session_id)) VARCHAR[64]
    }

    Table(user_profile, "user_profile\n(Some info of user)") {
  2. QuantumGhost revised this gist Apr 5, 2016. 2 changed files with 4 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions example.puml
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    @startuml
    ' uncomment the line below if you're using computer with a retina display
    ' skinparam dpi 300
    !define Table(name,desc) class name as "desc" << (T,#FFAAAA) >>
    ' we use bold for primary key
    ' green color for unique
    2 changes: 2 additions & 0 deletions template.puml
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    @startuml
    ' uncomment the line below if you're using computer with a retina display
    ' skinparam dpi 300
    !define Table(name,desc) class name as "desc" << (T,#FFAAAA) >>
    ' we use bold for primary key
    ' green color for unique
  3. QuantumGhost revised this gist Apr 5, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions template.puml
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,7 @@
    ' <i></i>
    ' <back:COLOR></color>, where color is a color name or html color code
    ' (#FFAACC)
    ' see: http://plantuml.com/classes.html#More
    hide methods
    hide stereotypes

  4. QuantumGhost revised this gist Apr 5, 2016. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions example.puml
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,11 @@
    !define primary_key(x) <b>x</b>
    !define unique(x) <color:green>x</color>
    !define not_null(x) <u>x</u>
    ' other tags available:
    ' <i></i>
    ' <back:COLOR></color>, where color is a color name or html color code
    ' (#FFAACC)
    ' see: http://plantuml.com/classes.html#More
    hide methods
    hide stereotypes

  5. QuantumGhost revised this gist Apr 5, 2016. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions template.puml
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,10 @@
    !define primary_key(x) <b>x</b>
    !define unique(x) <color:green>x</color>
    !define not_null(x) <u>x</u>
    ' other tags available:
    ' <i></i>
    ' <back:COLOR></color>, where color is a color name or html color code
    ' (#FFAACC)
    hide methods
    hide stereotypes

  6. QuantumGhost revised this gist Apr 5, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions example.svg
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  7. QuantumGhost created this gist Apr 5, 2016.
    53 changes: 53 additions & 0 deletions example.puml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    @startuml
    !define Table(name,desc) class name as "desc" << (T,#FFAAAA) >>
    ' we use bold for primary key
    ' green color for unique
    ' and underscore for not_null
    !define primary_key(x) <b>x</b>
    !define unique(x) <color:green>x</color>
    !define not_null(x) <u>x</u>
    hide methods
    hide stereotypes

    ' entities

    Table(user, "user\n(User in our system)") {
    primary_key(id) INTEGER
    not_null(unique(username)) VARCHAR[32]
    not_null(password) VARCHAR[64]
    }

    Table(session, "session\n(session for user)") {
    primary_key(id) INTEGER
    not_null(user_id) INTEGER
    not_null(unique(session_id) VARCHAR[64]
    }

    Table(user_profile, "user_profile\n(Some info of user)") {
    primary_key(user_id) INTEGER
    age SMALLINT
    gender SMALLINT
    birthday DATETIME
    }

    Table(group, "group\n(group of users)") {
    primary_key(id) INTEGER
    not_null(name) VARCHAR[32]
    }

    Table(user_group, "user_group\n(relationship of user and group)") {
    primary_key(user_id) INTEGER
    primary_key(group_id) INTEGER
    joined_at DATETIME
    }

    ' relationships
    ' one-to-one relationship
    user -- user_profile : "A user only \nhas one profile"
    ' one to may relationship
    user --> session : "A user may have\n many sessions"
    ' many to many relationship
    ' Add mark if you like
    user "1" --> "*" user_group : "A user may be \nin many groups"
    group "1" --> "0..N" user_group : "A group may \ncontain many users"
    @enduml
    16 changes: 16 additions & 0 deletions template.puml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    @startuml
    !define Table(name,desc) class name as "desc" << (T,#FFAAAA) >>
    ' we use bold for primary key
    ' green color for unique
    ' and underscore for not_null
    !define primary_key(x) <b>x</b>
    !define unique(x) <color:green>x</color>
    !define not_null(x) <u>x</u>
    hide methods
    hide stereotypes

    ' entities

    ' relationships

    @enduml