使用 d2lang 和 sql_table 形状,我可以在列描述中添加注释吗?

问题描述 投票:0回答:1

正如标题所述,最好在 ER 表中添加注释。比如:

car: {
  shape: sql_table
  id: int {constraint: primary_key}
  make: string "This is a comment describing the column"
}

或者也许

car: {
  shape: sql_table
  id: int {constraint: primary_key}
  make: string {comment: "This is a comment describing the column"}
}

与 ER 中的 Mermaid 评论进行比较:https://mermaid.js.org/syntax/entityRelationshipDiagram.html

PERSON {
    string driversLicense PK "The license #"
    string(99) firstName "Only 99 characters are allowed"
}
d2lang
1个回答
0
投票

我在文档中没有看到执行此操作的官方方法,但您可以使用

constraint
字段来存储其他任何内容以及其他约束:

car: {
  shape: sql_table
  id: int {constraint: primary_key}
  make: string {constraint: ["This is a comment describing the column"; foreign_key]}
}

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.