File tree Expand file tree Collapse file tree 1 file changed +247
-0
lines changed
Expand file tree Collapse file tree 1 file changed +247
-0
lines changed Original file line number Diff line number Diff line change 1+ # Diagrams
2+
3+ ## Models
4+
5+
6+ ### Owned Entities
7+
8+ ``` mermaid
9+ classDiagram
10+ Address *-- Location : Location
11+ Person *-- Address : BusinessAddress
12+ Person o-- Address : PrivateAddress
13+
14+ class Location {
15+ +Country: string
16+ +City: string
17+ }
18+ class Address {
19+ +LineOne: string
20+ +LineTwo: string
21+ }
22+ class Person {
23+ +PersonId: int
24+ +FirstName: string
25+ +LastName: string
26+ }
27+ ```
28+
29+ ``` mermaid
30+ erDiagram
31+ People {
32+ int PersonId
33+ string FirstName
34+ string LastName
35+ string BusinessAdressLineOne
36+ string BusinessAddressLineTwo
37+ string BusinessCity
38+ string BusinessCountry
39+ int PrivateAddressId
40+ }
41+ PrivateAddresses {
42+ string LineOne
43+ string LineTwo
44+ string City
45+ string Country
46+ }
47+ ```
48+
49+ ### Table Splitting
50+
51+ ``` mermaid
52+ classDiagram
53+
54+ MenuItem "1" o--> "1" MenuDetails : Details
55+
56+ class MenuDetails {
57+ +MenuItemId: int
58+ +KitchenInfo: string
59+ +MenusSold: int
60+ }
61+ class MenuItem {
62+ +MenuItemId: int
63+ +Title: string
64+ +Subtitle: string
65+ +Price: decimal
66+ }
67+ ```
68+
69+ ``` mermaid
70+ erDiagram
71+ MenuItem {
72+ int MenuItemId
73+ string Title
74+ string Subtitle
75+ money Price
76+ string KitchenInfo
77+ int MenusSold
78+ }
79+ ```
80+
81+
82+ ##
83+
84+ ``` mermaid
85+ classDiagram
86+
87+ MenuItem "1" o--> "1" MenuDetails : Details
88+
89+ class MenuDetails {
90+ +MenuDetailsId: int
91+ +KitchenInfo: string
92+ +MenusSold: string
93+ +Price: decimal
94+ }
95+ class MenuItem {
96+ +MenuItemId: int
97+ +Title: string
98+ +Subtitle: string
99+ +Price: decimal
100+ }
101+ class MenuCard {
102+ +MenuCardId: int
103+ +Title: string
104+ }
105+ class Restaurant {
106+ +Name: string
107+ }
108+ ```
109+
110+ ## Inheritance
111+
112+ ## Table per Hierarchy (TPH)
113+
114+ TPH is a pattern where you have a base class and multiple derived classes. Each derived class has its own table. The base class table contains a discriminator column that identifies the type of the derived class. The derived class tables contain all the columns of the base class table plus their own columns.
115+
116+ ``` mermaid
117+ classDiagram
118+
119+ Payment <|-- CashPayment
120+ Payment <|-- CreditcardPayment
121+ class Payment {
122+ +PaymentId: int
123+ +Name: string
124+ +Amount: decimal
125+ }
126+
127+ class CashPayment {
128+ }
129+
130+ class CreditcardPayment {
131+ +CreditcardNumber: string
132+ }
133+ ```
134+
135+ ``` mermaid
136+ erDiagram
137+ Payments {
138+ int PaymentId
139+ string PaymentType
140+ string Name
141+ money Amount
142+ string CreditcardNumber
143+ }
144+ ```
145+
146+ ## Table per Type (TpT)
147+
148+ Table per type
149+
150+ ``` mermaid
151+ erDiagram
152+ Payments {
153+ int PaymentId
154+ string PaymentType
155+ string Name
156+ money Amount
157+
158+ }
159+
160+ CashPayments {
161+ int PaymentId
162+ }
163+
164+ CreditcardPayments {
165+ int PaymentId
166+ string CreditcardNumber
167+ }
168+ ```
169+
170+ ## Table per concrete Type (TcT)
171+
172+ ``` mermaid
173+ classDiagram
174+
175+ Payment <|-- CashPayment
176+ Payment <|-- CreditcardPayment
177+
178+ class Payment {
179+ <<abstract>>
180+ +PaymentId: int
181+ +Name: string
182+ +Amount: decimal
183+ }
184+
185+ class CashPayment {
186+ }
187+
188+ class CreditcardPayment {
189+ +CreditcardNumber: string
190+ }
191+ ```
192+
193+
194+ ``` mermaid
195+ erDiagram
196+ CashPayments {
197+ int PaymentId
198+ string Name
199+ money Amount
200+ }
201+
202+ CreditcardPayments {
203+ int PaymentId
204+ string Name
205+ money Amount
206+ string CreditcardNumber
207+ }
208+ ```
209+
210+ ## Many-to-many Relationships
211+
212+ ``` mermaid
213+ classDiagram
214+ Book "*" <--> "*" Person
215+
216+ class Book {
217+ +BookId: int
218+ +Title: string
219+ +Publisher: string
220+ }
221+
222+ class Person {
223+ +PersonId: int
224+ +FirstName: string
225+ +LastName: string
226+ }
227+ ```
228+
229+ ``` mermaid
230+ erDiagram
231+ Books {
232+ int BookId
233+ string Title
234+ string Publisher
235+ }
236+
237+ People {
238+ int PersonId
239+ string FirstName
240+ string LastName
241+ }
242+
243+ BookPeople {
244+ int BookId
245+ int PersonId
246+ }
247+ ```
You can’t perform that action at this time.
0 commit comments