Merge pull request #19979 from civicrm/5.36
[civicrm-core.git] / xml / schema / Contact / RelationshipCache.xml
1 <?xml version="1.0" encoding="iso-8859-1" ?>
2
3 <table>
4 <base>CRM/Contact</base>
5 <class>RelationshipCache</class>
6 <name>civicrm_relationship_cache</name>
7 <comment>The cache permutes information from the relationship table to facilitate querying. Every relationship is mapped to multiple records in the cache. Joins should begin on the near side and extract info from the far side.</comment>
8 <add>5.29</add>
9 <log>false</log>
10 <icon>fa-handshake-o</icon>
11 <title>Related Contact</title>
12 <field>
13 <name>id</name>
14 <type>int unsigned</type>
15 <title>Relationship Cache ID</title>
16 <required>true</required>
17 <comment>Relationship Cache ID</comment>
18 <html>
19 <type>Number</type>
20 </html>
21 <add>5.29</add>
22 </field>
23 <primaryKey>
24 <name>id</name>
25 <autoincrement>true</autoincrement>
26 </primaryKey>
27
28 <field>
29 <name>relationship_id</name>
30 <type>int unsigned</type>
31 <title>Relationship ID</title>
32 <required>true</required>
33 <comment>id of the relationship (FK to civicrm_relationship.id)</comment>
34 <html>
35 <label>Relationship</label>
36 </html>
37 <add>5.29</add>
38 <readonly>true</readonly>
39 </field>
40 <foreignKey>
41 <name>relationship_id</name>
42 <table>civicrm_relationship</table>
43 <key>id</key>
44 <add>5.29</add>
45 <onDelete>CASCADE</onDelete>
46 </foreignKey>
47
48 <field>
49 <name>relationship_type_id</name>
50 <type>int unsigned</type>
51 <title>Relationship Type ID</title>
52 <required>true</required>
53 <comment>id of the relationship type</comment>
54 <html>
55 <label>Relationship Type</label>
56 </html>
57 <add>5.29</add>
58 <readonly>true</readonly>
59 </field>
60 <foreignKey>
61 <name>relationship_type_id</name>
62 <table>civicrm_relationship_type</table>
63 <key>id</key>
64 <add>5.29</add>
65 <onDelete>CASCADE</onDelete>
66 </foreignKey>
67
68 <field>
69 <name>orientation</name>
70 <type>char</type>
71 <length>3</length>
72 <title>Orientation (a_b or b_a)</title>
73 <required>true</required>
74 <pseudoconstant>
75 <callback>CRM_Core_SelectValues::relationshipOrientation</callback>
76 </pseudoconstant>
77 <comment>The cache record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship.</comment>
78 <add>5.29</add>
79 <readonly>true</readonly>
80 </field>
81
82 <field>
83 <name>near_contact_id</name>
84 <type>int unsigned</type>
85 <title>Contact ID (Near side)</title>
86 <required>true</required>
87 <comment>id of the first contact</comment>
88 <add>5.29</add>
89 <html>
90 <type>EntityRef</type>
91 <label>Contact (Near side)</label>
92 </html>
93 <readonly>true</readonly>
94 </field>
95 <foreignKey>
96 <name>near_contact_id</name>
97 <table>civicrm_contact</table>
98 <key>id</key>
99 <add>5.29</add>
100 <onDelete>CASCADE</onDelete>
101 </foreignKey>
102
103 <field>
104 <name>near_relation</name>
105 <type>varchar</type>
106 <title>Relationship Name (to related contact)</title>
107 <length>64</length>
108 <comment>name for relationship of near_contact to far_contact.</comment>
109 <add>5.29</add>
110 <html>
111 <label>Relationship to contact</label>
112 </html>
113 <pseudoconstant>
114 <callback>CRM_Core_PseudoConstant::relationshipTypeOptions</callback>
115 </pseudoconstant>
116 <readonly>true</readonly>
117 </field>
118
119 <field>
120 <name>far_contact_id</name>
121 <type>int unsigned</type>
122 <title>Contact ID (Far side)</title>
123 <required>true</required>
124 <comment>id of the second contact</comment>
125 <add>5.29</add>
126 <html>
127 <type>EntityRef</type>
128 <label>Contact (Far side)</label>
129 </html>
130 <readonly>true</readonly>
131 </field>
132 <foreignKey>
133 <name>far_contact_id</name>
134 <table>civicrm_contact</table>
135 <key>id</key>
136 <add>5.29</add>
137 <onDelete>CASCADE</onDelete>
138 </foreignKey>
139
140 <field>
141 <name>far_relation</name>
142 <type>varchar</type>
143 <title>Relationship Name (from related contact)</title>
144 <length>64</length>
145 <comment>name for relationship of far_contact to near_contact.</comment>
146 <add>5.29</add>
147 <html>
148 <label>Relationship from contact</label>
149 </html>
150 <pseudoconstant>
151 <callback>CRM_Core_PseudoConstant::relationshipTypeOptions</callback>
152 </pseudoconstant>
153 <readonly>true</readonly>
154 </field>
155
156 <index>
157 <name>UI_relationship</name>
158 <fieldName>relationship_id</fieldName>
159 <fieldName>orientation</fieldName>
160 <unique>true</unique>
161 <add>5.29</add>
162 </index>
163 <index>
164 <!-- Ex: select ... from contact inner join relcache on contact.id=relcache.near_contact_id and near_relation = 'Parent of' -->
165 <name>index_nearid_nearrelation</name>
166 <fieldName>near_contact_id</fieldName>
167 <fieldName>near_relation</fieldName>
168 <add>5.29</add>
169 </index>
170 <index>
171 <!-- Ex: select ... from contact inner join relcache on contact.id=relcache.near_contact_id and far_relation = 'Child of' -->
172 <name>index_nearid_farrelation</name>
173 <fieldName>near_contact_id</fieldName>
174 <fieldName>far_relation</fieldName>
175 <add>5.29</add>
176 </index>
177 <index>
178 <!-- Ex: select relation, count(*) from relcache group by near_relation -->
179 <name>index_near_relation</name>
180 <fieldName>near_relation</fieldName>
181 <add>5.29</add>
182 </index>
183
184 <!-- Passive mirror fields -->
185
186 <field>
187 <name>is_active</name>
188 <type>boolean</type>
189 <title>Relationship Is Active</title>
190 <default>1</default>
191 <comment>is the relationship active ?</comment>
192 <add>5.29</add>
193 <html>
194 <type>CheckBox</type>
195 </html>
196 <readonly>true</readonly>
197 </field>
198 <field>
199 <name>start_date</name>
200 <uniqueName>relationship_start_date</uniqueName>
201 <type>date</type>
202 <title>Relationship Start Date</title>
203 <comment>date when the relationship started</comment>
204 <add>5.29</add>
205 <html>
206 <type>Select Date</type>
207 <formatType>activityDate</formatType>
208 </html>
209 <readonly>true</readonly>
210 </field>
211 <field>
212 <name>end_date</name>
213 <uniqueName>relationship_end_date</uniqueName>
214 <type>date</type>
215 <title>Relationship End Date</title>
216 <comment>date when the relationship ended</comment>
217 <add>5.29</add>
218 <html>
219 <type>Select Date</type>
220 <formatType>activityDate</formatType>
221 </html>
222 <readonly>true</readonly>
223 </field>
224 </table>