annotate readme.md @ 2:035de8b7b18e

Temporary commit, refactoring, added readme
author cin
date Sun, 25 Feb 2018 17:12:33 +0300
parents
children d3542662cf70
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
1
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
2 # SINOPSYS
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
3
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
4 ```xml
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
5 <package
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
6 xmlns="http://implab.org/schemas/data-model.v1.xsd"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
7 name="simple-model"
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
8 >
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
9 <!-- import predefined types -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
10 <import href="types.xml"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
11
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
12 <!-- define entity -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
13 <entity name="Order">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
14 <!-- define primary key -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
15 <primaryKey name="Id" type="uuid"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
16
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
17 <!-- define simple property -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
18 <property name="OrderDate" type="dateTime"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
19
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
20 <!-- define hasA relation -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
21 <hasA name="Item" type="Item">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
22 <!-- specified a property which holds reference -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
23 <thisKey name="ItemId"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
24 </hasA>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
25
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
26 <!-- define hasMany relation -->
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
27 <hasMany name="Comments" type="OrderComment">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
28 <otherKey name="Order"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
29 </hasMany>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
30 </entity>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
31
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
32 <entity name="Item">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
33 <primaryKey name="Id" type="uuid"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
34
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
35 <property name="Title" type="string" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
36
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
37 </entity>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
38
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
39 <entity name="OrderComment">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
40 <primaryKey name="Id" type="uuid" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
41
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
42 <property name="Comment" type="text" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
43
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
44 <property name="Date" type="dateTime" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
45
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
46 <hasA name="Order" type="Order">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
47 <thisKey name="OrderId" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
48 </hasA>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
49 </entity>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
50 </package>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
51 ```
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
52
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
53 # DESCRIPTION
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
54
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
55 Описание модели включает в себя описание наборов сущностей, каждый набор
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
56 называется пакетом.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
57
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
58 В пакете содержатся описания сущностей, а также объявления внешних типов,
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
59 которые используются при описании сущностей.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
60
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
61 Для уменьшения количества дублируемого кода, а также для упрощения читаемости
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
62 и упрощения сопровождения существует возможность импортирования уже объявленных
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
63 пакетов. В процессе сборки происходит предварительная обработка, которая
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
64 использует все директивы `import` для составления общего модуля, состоящего
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
65 из нескольких пакетов, при этом пакет с которого был начат процесс сборки
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
66 называется первичным и после окончания предварительной обработки для него будет
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
67 выполнена сборка.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
68
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
69 Каждая сущность модели состоит из нескольких типов членов, это
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
70 * Свойства - используются для хранения состояния сущности, аналогичны столбцам в таблице
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
71 * Ключи - информация для идентификации записей, каждая запись должна иметь по крайней мере первичный ключ.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
72 * Отношения - информация о связях между сущностями
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
73
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
74 ## Properties
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
75
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
76 ## PrimaryKey
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
77
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
78 Внешний ключ представляет собой набор уникальных данных, позволяющий однозначно
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
79 идентифицировать запись, при этом внешний ключ может состоять как из одного
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
80 поля (простые), так и из нескольких (составные)
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
81
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
82 Простые первичные ключи
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
83
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
84 ```xml
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
85 <primaryKey name="Id" type="uuid"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
86 ```
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
87
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
88 Составные первичные ключи
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
89
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
90 ```xml
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
91 <primaryKey name="Id">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
92 <member name="Owner"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
93 <member name="SeqNum"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
94 </primaryKey>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
95 <property name="SeqNum" type="integer"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
96 <hasA name="Owner" type="User">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
97 <thisKey name="UserId" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
98 </hasA>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
99 ```
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
100 При описании составных ключей перечисляется набор членов сущности, которые
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
101 будут образовывать уникальный набор данных для первичного ключа, следует
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
102 отметить, что не все отношения храняться в самой сущности, например,
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
103 `hasMany` может хранится не в записях самой сущности, а в записях связанной
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
104 сущности, такие отношения нельзя включать в первичный ключ.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
105 Отношение `hasA`, напротив, как парвило хранится в свойствах самой сущности
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
106 и включение его в первичный ключ означает автоматическое включение всех
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
107 свойств.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
108
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
109 ## Relations
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
110
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
111 ### hasA
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
112
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
113 `hasA` это отношение, при котором текущей сущности может
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
114 соответсвовать одна связанная сущность. При реализации
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
115 данного отношение может быть указано свойство, используемое
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
116 для хранения ссылки при помощи дочернего элемента `thisKey`
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
117
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
118 `thisKey` указывает способ реализации отношения, при котором
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
119 в текущей сущности хранится информация для осуществления связи.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
120
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
121 По-умолчанию для связи используются первичные ключи, что
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
122 позволяет автоматически определять набор и типы необходимых
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
123 свойств для хранения ссылки.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
124
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
125 ```xml
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
126 <hasA name="Order" type="Order" optional="true">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
127 <thisKey name="OrderId" />
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
128 </hasA>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
129 ```
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
130
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
131 В случях когда первичный ключ является сложным можно указать
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
132 префикс или явно перечислить свойства в которых будет хранится
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
133 связь
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
134
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
135 ```xml
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
136 <property name="UserId" type="uuid"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
137 <property name="MemberNo" type="integer"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
138 <hasA name="Membership" type="Membership">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
139 <thisKey>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
140 <member name="UserId"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
141 <member name="MemberNo"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
142 </thisKey>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
143 </hasA>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
144 ```
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
145
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
146 ### hasMany
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
147
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
148 Отношение при котором с текущей записью связано произвольное
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
149 количество записей другой сущности.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
150
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
151 Как правило это отношение является комплиментарным к `hasA` с другой стороны.
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
152
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
153 ```xml
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
154 <hasMany name="Roles" type="Role">
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
155 <otherKey name="User"/>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
156 </hasMany>
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
157 ```
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
158
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
159 `otherKey` указывает имя члена в связанной сущности, который хранит информацию
035de8b7b18e Temporary commit, refactoring, added readme
cin
parents:
diff changeset
160 о связи, это может быть оношение, свойство или ключ.