728x90
shape 속성울 통해서 엔티티-관계 다이어그램(ERD)을 쉽게 다이어그램으로 나타낼 수 있습니다.
예는 다음과 같습니다.
basic_table: {
shape: sql_table
id: int {constraint: primary_key}
last_updated: timestamp with time zone
}
constraint라는 것을 통해 sql 테이블에서의 제약을 표시할 수 있습니다.
결과는 다음과 같습니다.
다음과 같이 자동적으로 강조되는 것을 확인할 수 있습니다.
제약 조건에서 인식하는 조건들은 아래와 같습니다.
조건 축약어
primary_key | PK |
foreign_key | FK |
unique | UNQ |
아래는 외래 키를 연결시키는 예제입니다.
objects: {
shape: sql_table
id: int {constraint: primary_key}
disk: int {constraint: foreign_key}
json: jsonb {constraint: unique}
last_updated: timestamp with time zone
}
disks: {
shape: sql_table
id: int {constraint: primary_key}
}
objects.disk -> disks.id
다음과 같이 출력 됨을 확인 하실 수 있습니다.
sql_table의 경우에도 컨테이너와 마찬가지로 연결하고 중첩 시켜 사용가능합니다.
아래가 그 예시입니다.
cloud: {
disks: {
shape: sql_table
id: int {constraint: primary_key}
}
blocks: {
shape: sql_table
id: int {constraint: primary_key}
disk: int {constraint: foreign_key}
blob: blob
}
blocks.disk -> disks.id
AWS S3 Vancouver -> disks
}
아래는 결과입니다.
이상으로 마치겠습니다.
'D2Lang' 카테고리의 다른 글
[D2Lang] 10. D2의 Sequence 다이어그램의 사용법을 알아보자! (1) (0) | 2023.05.08 |
---|---|
[D2Lang] 9. D2의 UML 클래스의 사용법을 알아보자! (0) | 2023.05.07 |
[D2Lang] 7. D2의 Icons & Images의 사용법을 알아보자! (0) | 2023.05.05 |
[D2Lang] 6. window에서 D2 CLI 설치 및 내보내기(svg, png)를 알아보자! (0) | 2023.05.04 |
[D2Lang] 5. D2의 Text & Code를 알아보자! (0) | 2023.05.03 |