Merge pull request #19525 from eileenmcnaughton/member_soft
[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 </field>
39 <foreignKey>
40 <name>relationship_id</name>
41 <table>civicrm_relationship</table>
42 <key>id</key>
43 <add>5.29</add>
44 <onDelete>CASCADE</onDelete>
45 </foreignKey>
46
47 <field>
48 <name>relationship_type_id</name>
49 <type>int unsigned</type>
50 <title>Relationship Type ID</title>
51 <required>true</required>
52 <comment>id of the relationship type</comment>
53 <html>
54 <label>Relationship Type</label>
55 </html>
56 <add>5.29</add>
57 </field>
58 <foreignKey>
59 <name>relationship_type_id</name>
60 <table>civicrm_relationship_type</table>
61 <key>id</key>
62 <add>5.29</add>
63 <onDelete>CASCADE</onDelete>
64 </foreignKey>
65
66 <field>
67 <name>orientation</name>
68 <type>char</type>
69 <length>3</length>
70 <title>Orientation (a_b or b_a)</title>
71 <required>true</required>
72 <pseudoconstant>
73 <callback>CRM_Core_SelectValues::relationshipOrientation</callback>
74 </pseudoconstant>
75 <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>
76 <add>5.29</add>
77 </field>
78
79 <field>
80 <name>near_contact_id</name>
81 <type>int unsigned</type>
82 <title>Contact ID (Near side)</title>
83 <required>true</required>
84 <comment>id of the first contact</comment>
85 <add>5.29</add>
86 <html>
87 <type>EntityRef</type>
88 <label>Contact (Near side)</label>
89 </html>
90 </field>
91 <foreignKey>
92 <name>near_contact_id</name>
93 <table>civicrm_contact</table>
94 <key>id</key>
95 <add>5.29</add>
96 <onDelete>CASCADE</onDelete>
97 </foreignKey>
98
99 <field>
100 <name>near_relation</name>
101 <type>varchar</type>
102 <title>Relationship Name (to related contact)</title>
103 <length>64</length>
104 <comment>name for relationship of near_contact to far_contact.</comment>
105 <add>5.29</add>
106 <html>
107 <label>Relationship to contact</label>
108 </html>
109 <pseudoconstant>
110 <callback>CRM_Core_PseudoConstant::relationshipTypeOptions</callback>
111 </pseudoconstant>
112 </field>
113
114 <field>
115 <name>far_contact_id</name>
116 <type>int unsigned</type>
117 <title>Contact ID (Far side)</title>
118 <required>true</required>
119 <comment>id of the second contact</comment>
120 <add>5.29</add>
121 <html>
122 <type>EntityRef</type>
123 <label>Contact (Far side)</label>
124 </html>
125 </field>
126 <foreignKey>
127 <name>far_contact_id</name>
128 <table>civicrm_contact</table>
129 <key>id</key>
130 <add>5.29</add>
131 <onDelete>CASCADE</onDelete>
132 </foreignKey>
133
134 <field>
135 <name>far_relation</name>
136 <type>varchar</type>
137 <title>Relationship Name (from related contact)</title>
138 <length>64</length>
139 <comment>name for relationship of far_contact to near_contact.</comment>
140 <add>5.29</add>
141 <html>
142 <label>Relationship from contact</label>
143 </html>
144 <pseudoconstant>
145 <callback>CRM_Core_PseudoConstant::relationshipTypeOptions</callback>
146 </pseudoconstant>
147 </field>
148
149 <index>
150 <name>UI_relationship</name>
151 <fieldName>relationship_id</fieldName>
152 <fieldName>orientation</fieldName>
153 <unique>true</unique>
154 <add>5.29</add>
155 </index>
156 <index>
157 <!-- Ex: select ... from contact inner join relcache on contact.id=relcache.near_contact_id and near_relation = 'Parent of' -->
158 <name>index_nearid_nearrelation</name>
159 <fieldName>near_contact_id</fieldName>
160 <fieldName>near_relation</fieldName>
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 far_relation = 'Child of' -->
165 <name>index_nearid_farrelation</name>
166 <fieldName>near_contact_id</fieldName>
167 <fieldName>far_relation</fieldName>
168 <add>5.29</add>
169 </index>
170 <index>
171 <!-- Ex: select relation, count(*) from relcache group by near_relation -->
172 <name>index_near_relation</name>
173 <fieldName>near_relation</fieldName>
174 <add>5.29</add>
175 </index>
176
177 <!-- Passive mirror fields -->
178
179 <field>
180 <name>is_active</name>
181 <type>boolean</type>
182 <title>Relationship Is Active</title>
183 <default>1</default>
184 <comment>is the relationship active ?</comment>
185 <add>5.29</add>
186 <html>
187 <type>CheckBox</type>
188 </html>
189 </field>
190 <field>
191 <name>start_date</name>
192 <uniqueName>relationship_start_date</uniqueName>
193 <type>date</type>
194 <title>Relationship Start Date</title>
195 <comment>date when the relationship started</comment>
196 <add>5.29</add>
197 <html>
198 <type>Select Date</type>
199 <formatType>activityDate</formatType>
200 </html>
201 </field>
202 <field>
203 <name>end_date</name>
204 <uniqueName>relationship_end_date</uniqueName>
205 <type>date</type>
206 <title>Relationship End Date</title>
207 <comment>date when the relationship ended</comment>
208 <add>5.29</add>
209 <html>
210 <type>Select Date</type>
211 <formatType>activityDate</formatType>
212 </html>
213 </field>
214 </table>