Skip to content

Commit a928219

Browse files
committed
diagram maded by mermaid
1 parent e4cbaf5 commit a928219

File tree

4 files changed

+422
-15
lines changed

4 files changed

+422
-15
lines changed

docs/DBMS/Entity-Relational Model/dbms-generalization-and-aggregation.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ As mentioned above, the process of generalizing entities, where the generalized
3030
| Crow | Bird |
3131
| Dove | Bird |
3232

33-
![generalization](https://www.tutorialspoint.com/dbms/images/generalization.png)
33+
```mermaid
34+
---
35+
title: Generalization Example
36+
---
37+
erDiagram
38+
PIGEON }|..|{ BIRD : generalizes
39+
HOUSE_SPARROW }|..|{ BIRD : generalizes
40+
CROW }|..|{ BIRD : generalizes
41+
DOVE }|..|{ BIRD : generalizes
42+
```
3443

3544
## Specialization
3645

@@ -42,7 +51,16 @@ Specialization is the opposite of generalization. In specialization, a group of
4251
|----------------|--------------------------|
4352
| Person | Employee, Employer, Customer, Vendor |
4453

45-
![specialization](https://www.tutorialspoint.com/dbms/images/specialization.png)
54+
```mermaid
55+
---
56+
title: Specialization Example
57+
---
58+
erDiagram
59+
PERSON ||--o{ EMPLOYEE : specializes
60+
PERSON ||--o{ EMPLOYER : specializes
61+
PERSON ||--o{ CUSTOMER : specializes
62+
PERSON ||--o{ VENDOR : specializes
63+
```
4664

4765
Similarly, in a school database, persons can be specialized as teacher, student, or a staff, based on what role they play in school as entities.
4866

@@ -54,10 +72,30 @@ Inheritance is an important feature of Generalization and Specialization. It all
5472

5573
### Example of Inheritance
5674

57-
![inheritance](https://www.tutorialspoint.com/dbms/images/inheritance.png)
58-
5975
| Higher-level Entity | Attributes | Lower-level Entities |
6076
|---------------------|-----------------------------|------------------------|
6177
| Person | Name, Age, Gender | Student, Teacher |
6278

79+
```mermaid
80+
---
81+
title: Inheritance Example
82+
---
83+
erDiagram
84+
PERSON {
85+
string name
86+
int age
87+
string gender
88+
}
89+
STUDENT {
90+
string school
91+
string grade
92+
}
93+
TEACHER {
94+
string subject
95+
string department
96+
}
97+
PERSON ||--o{ STUDENT : inherits
98+
PERSON ||--o{ TEACHER : inherits
99+
```
100+
63101
For example, the attributes of a Person class such as name, age, and gender can be inherited by lower-level entities such as Student or Teacher.

docs/DBMS/Entity-Relational Model/er-diagram-representation.md

Lines changed: 108 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,85 @@ Let us now learn how the ER Model is represented by means of an ER diagram. Any
1818

1919
Entities are represented by means of rectangles. Rectangles are named with the entity set they represent.
2020

21-
![entities](https://www.tutorialspoint.com/dbms/images/entities.png)
21+
```mermaid
22+
---
23+
title: Entity Representation
24+
---
25+
erDiagram
26+
ENTITY {
27+
string attribute1
28+
int attribute2
29+
}
30+
```
2231

2332
## Attributes
2433

2534
### Simple Attributes
2635

2736
Attributes are the properties of entities. Attributes are represented by means of ellipses. Every ellipse represents one attribute and is directly connected to its entity (rectangle).
2837

29-
![er_attributes](https://www.tutorialspoint.com/dbms/images/er_attributes.png)
38+
```mermaid
39+
---
40+
title: Simple Attributes
41+
---
42+
erDiagram
43+
ENTITY {
44+
string attribute1
45+
}
46+
```
3047

3148
### Composite Attributes
3249

3350
If the attributes are composite, they are further divided in a tree-like structure. Every node is then connected to its attribute. Composite attributes are represented by ellipses that are connected with an ellipse.
3451

35-
![er_attributes_composite](https://www.tutorialspoint.com/dbms/images/er_attributes_composite.png)
52+
```mermaid
53+
---
54+
title: Composite Attributes
55+
---
56+
erDiagram
57+
ENTITY {
58+
string attribute1
59+
}
60+
attribute1 {
61+
string sub_attribute1
62+
string sub_attribute2
63+
}
64+
ENTITY ||--o{ attribute1 : has
65+
```
3666

3767
### Multivalued Attributes
3868

39-
Multivalued attributes are depicted by double ellipse.
69+
Multivalued attributes are depicted by double ellipses.
4070

41-
![er_attributes_multivalued](https://www.tutorialspoint.com/dbms/images/er_attributes_multivalued.png)
71+
```mermaid
72+
---
73+
title: Multivalued Attributes
74+
---
75+
erDiagram
76+
ENTITY {
77+
string attribute1
78+
int attribute2
79+
string[] multivalued_attribute
80+
}
81+
ENTITY ||--o{ multivalued_attribute : has
82+
```
4283

4384
### Derived Attributes
4485

45-
Derived attributes are depicted by dashed ellipse.
86+
Derived attributes are depicted by dashed ellipses.
4687

47-
![er_attributes_derived](https://www.tutorialspoint.com/dbms/images/er_attributes_derived.png)
88+
```mermaid
89+
---
90+
title: Derived Attributes
91+
---
92+
erDiagram
93+
ENTITY {
94+
string attribute1
95+
int attribute2
96+
int derived_attribute
97+
}
98+
ENTITY ||--o{ derived_attribute : derives
99+
```
48100

49101
## Relationship
50102

@@ -58,24 +110,72 @@ A relationship where two entities are participating is called a binary relations
58110

59111
When only one instance of an entity is associated with the relationship, it is marked as '1:1'. The following image reflects that only one instance of each entity should be associated with the relationship. It depicts one-to-one relationship.
60112

113+
```mermaid
114+
---
115+
title: One-to-One Relationship
116+
---
117+
erDiagram
118+
ENTITY1 ||--|| ENTITY2 : relationship
119+
```
120+
61121
#### One-to-Many
62122

63123
When more than one instance of an entity is associated with a relationship, it is marked as '1:N'. The following image reflects that only one instance of entity on the left and more than one instance of an entity on the right can be associated with the relationship. It depicts one-to-many relationship.
64124

125+
```mermaid
126+
---
127+
title: One-to-Many Relationship
128+
---
129+
erDiagram
130+
ENTITY1 ||--o{ ENTITY2 : relationship
131+
```
132+
65133
#### Many-to-One
66134

67135
When more than one instance of entity is associated with the relationship, it is marked as 'N:1'. The following image reflects that more than one instance of an entity on the left and only one instance of an entity on the right can be associated with the relationship. It depicts many-to-one relationship.
68136

137+
```mermaid
138+
---
139+
title: Many-to-One Relationship
140+
---
141+
erDiagram
142+
ENTITY1 }o--|| ENTITY2 : relationship
143+
```
144+
69145
#### Many-to-Many
70146

71147
The following image reflects that more than one instance of an entity on the left and more than one instance of an entity on the right can be associated with the relationship. It depicts many-to-many relationship.
72148

149+
```mermaid
150+
---
151+
title: Many-to-Many Relationship
152+
---
153+
erDiagram
154+
ENTITY1 }o--o{ ENTITY2 : relationship
155+
```
156+
73157
### Participation Constraints
74158

75159
#### Total Participation
76160

77161
Each entity is involved in the relationship. Total participation is represented by double lines.
78162

163+
```mermaid
164+
---
165+
title: Total Participation
166+
---
167+
erDiagram
168+
ENTITY1 ||--|| ENTITY2 : relationship
169+
```
170+
79171
#### Partial Participation
80172

81-
Not all entities are involved in the relationship. Partial participation is represented by single lines.
173+
Not all entities are involved in the relationship. Partial participation is represented by single lines.
174+
175+
```mermaid
176+
---
177+
title: Partial Participation
178+
---
179+
erDiagram
180+
ENTITY1 }o--|| ENTITY2 : relationship
181+
```

docs/DBMS/data-models.md

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,27 @@ Flat data models were the earliest, where all data was kept on the same plane. H
1919

2020
The Entity-Relationship (ER) Model is based on real-world entities and their relationships. It creates entity sets, relationship sets, attributes, and constraints, making it suitable for conceptual database design.
2121

22-
![er_model_intro](https://www.tutorialspoint.com/dbms/images/er_model_intro.png)
22+
```mermaid
23+
---
24+
title: ER Model Example
25+
---
26+
erDiagram
27+
STUDENT {
28+
string name
29+
int age
30+
string class
31+
}
32+
TEACHER {
33+
string name
34+
string subject
35+
}
36+
COURSE {
37+
string name
38+
int credits
39+
}
40+
STUDENT ||--o{ COURSE : enrolls
41+
TEACHER ||--o{ COURSE : teaches
42+
```
2343

2444
### Concepts of ER Model
2545

@@ -30,12 +50,41 @@ The Entity-Relationship (ER) Model is based on real-world entities and their rel
3050

3151
The Relational Model is the most popular data model in DBMS, based on first-order predicate logic. It defines a table as an n-ary relation.
3252

33-
![relational_model_table](https://www.tutorialspoint.com/dbms/images/relational_model_table.png)
53+
```mermaid
54+
---
55+
title: Relational Model Table Example
56+
---
57+
erDiagram
58+
CUSTOMER {
59+
int id
60+
string name
61+
string address
62+
}
63+
ORDER {
64+
int id
65+
date orderDate
66+
float amount
67+
}
68+
LINE_ITEM {
69+
int id
70+
int quantity
71+
float price
72+
}
73+
CUSTOMER ||--o{ ORDER : places
74+
ORDER ||--|{ LINE_ITEM : contains
75+
CUSTOMER }|..|{ DELIVERY_ADDRESS : uses
76+
DELIVERY_ADDRESS {
77+
int id
78+
string street
79+
string city
80+
string zip
81+
}
82+
```
3483

3584
### Highlights of Relational Model
3685

3786
- Data stored in tables (relations).
3887
- Relations can be normalized.
3988
- Normalized relations contain atomic values.
4089
- Each row in a relation has a unique value.
41-
- Columns in a relation contain values from the same domain.
90+
- Columns in a relation contain values from the same domain.

0 commit comments

Comments
 (0)