-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforeign_keys.sql
executable file
·235 lines (235 loc) · 28.1 KB
/
foreign_keys.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
alter table ehealth_system add constraint foreign key(lkp_title) REFERENCES tlkp_choices (int_choiceid);
alter table ehealth_system add constraint foreign key(lkp_gender) REFERENCES tlkp_choices (int_choiceid);
alter table ehealth_system add constraint foreign key(lkp_roleid) REFERENCES tlkp_choices (int_choiceid);
alter table ehealth_system add constraint foreign key(lkp_moduleid) REFERENCES tlkp_choices (int_choiceid);
alter table ehealth_system add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact (int_contactid);
alter table ehealth_system add constraint FOREIGN KEY(lkp_addrtype) REFERENCES tlkp_choices (int_choiceid);
alter table ehealth_system add constraint FOREIGN KEY(lkp_city) REFERENCES tlkp_choices (int_choiceid);
alter table ehealth_system add constraint FOREIGN KEY(lkp_state) REFERENCES tlkp_choices (int_choiceid);
alter table ehealth_system add constraint FOREIGN KEY(lkp_profession) references tlkp_choices (int_choiceid);
alter table ehealth_system add constraint FOREIGN KEY(lkp_facility) references tlkp_choices (int_choiceid);
alter table ehealth_system add constraint FOREIGN KEY(int_resourceid) REFERENCES tbl_resource (int_resourceid);
alter table ehealth_system add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact (int_contactid);
alter table ehealth_system add constraint FOREIGN KEY(lkp_status) references tlkp_choices (int_choiceid);
alter table ehealth_system add constraint FOREIGN KEY(int_bookingid) REFERENCES tbl_resourcebookings(int_bookingid);
alter table ehealth_system add constraint FOREIGN KEY(int_childof) REFERENCES tbl_chainlink(int_linkid);
alter table ehealth_system add constraint foreign key(int_fromlinkid) references tbl_chainlink (int_linkid);
alter table ehealth_system add constraint foreign key(int_deftolinkid) references tbl_chainlink (int_linkid);
alter table ehealth_system add constraint foreign key(int_lowtolinkid) references tbl_chainlink (int_linkid);
alter table ehealth_system add constraint foreign key(int_hightolinkid) references tbl_chainlink (int_linkid);
alter table ehealth_system add constraint FOREIGN KEY(int_contactid) references tbl_contact(int_contactid);
alter table ehealth_system add constraint FOREIGN KEY(int_pinid) references tbl_linkpin(int_pinid);
alter table ehealth_system add constraint FOREIGN KEY(int_linkid) references tbl_chainlink(int_linkid);
alter table kortex.sql add constraint ALTER TABLE TBL_ACCOUNT ADD CONSTRAINT FK_ACCTYPE FOREIGN KEY (INT_ACCTYPEID) REFERENCES TLKP_ACCTYPE (INT_ACCTYPEID);
alter table kortex.sql add constraint ALTER TABLE TBL_ACCOUNT ADD FOREIGN KEY (INT_OWNERID) REFERENCES TBL_USER (INT_USERID);
alter table kortex.sql add constraint ALTER TABLE TBL_ACCOUNT ADD FOREIGN KEY (INT_CHILDOF) REFERENCES TBL_ACCOUNT (INT_ACCOUNTID);
alter table kortex.sql add constraint ALTER TABLE TBL_CONTACT ADD FOREIGN KEY (INT_LOCALITY) REFERENCES TLKP_LOCALITY (INT_LOCALITYID);
alter table kortex.sql add constraint ALTER TABLE TBL_HISTORY ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID);
alter table kortex.sql add constraint ALTER TABLE TBL_INVITEM ADD FOREIGN KEY (INT_OWNERID) REFERENCES TBL_USER (INT_USERID);
alter table kortex.sql add constraint ALTER TABLE TBL_INVITEM ADD FOREIGN KEY (INT_TYPEID) REFERENCES TLKP_INVITEMTYPE (INT_TYPEID);
alter table kortex.sql add constraint ALTER TABLE TBL_INVITEM ADD FOREIGN KEY (INT_MODELID INT_MANUFID) REFERENCES TLKP_INVMANUFMODEL (INT_MODELID INT_MANUFID);
alter table kortex.sql add constraint ALTER TABLE TBL_OPTION ADD FOREIGN KEY (INT_CHILDOF) REFERENCES TBL_OPTION (INT_OPTIONID);
alter table kortex.sql add constraint ALTER TABLE TBL_OPTION ADD FOREIGN KEY (INT_SECTIONID) REFERENCES TBL_SECTION (INT_SECTIONID);
alter table kortex.sql add constraint ALTER TABLE TBL_SCHEDULE ADD FOREIGN KEY (INT_TASKID) REFERENCES TBL_TASK (INT_TASKID);
alter table kortex.sql add constraint ALTER TABLE TBL_SCHEDULE ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID);
alter table kortex.sql add constraint ALTER TABLE TBL_TASK ADD CONSTRAINT FK_CONTACT FOREIGN KEY (INT_CONTACTID) REFERENCES TBL_CONTACT (INT_CONTACTID);
alter table kortex.sql add constraint ALTER TABLE TBL_TASK ADD FOREIGN KEY (INT_CREATEDBY) REFERENCES TBL_USER (INT_USERID);
alter table kortex.sql add constraint ALTER TABLE TBL_TASK ADD FOREIGN KEY (INT_CREATEDFOR) REFERENCES TBL_USER (INT_USERID);
alter table kortex.sql add constraint ALTER TABLE TBL_TASKALLOC ADD FOREIGN KEY (INT_TASKID) REFERENCES TBL_TASK (INT_TASKID) ON UPDATE CASCADE;
alter table kortex.sql add constraint ALTER TABLE TBL_TASKALLOC ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID) ON UPDATE CASCADE;
alter table kortex.sql add constraint ALTER TABLE TBL_TASKEVENT ADD FOREIGN KEY (INT_TASKID) REFERENCES TBL_TASK (INT_TASKID);
alter table kortex.sql add constraint ALTER TABLE TBL_TASKEVENT ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID);
alter table kortex.sql add constraint ALTER TABLE TBL_TASKNOTES ADD FOREIGN KEY (INT_TASKID) REFERENCES TBL_TASK (INT_TASKID) ON UPDATE CASCADE;
alter table kortex.sql add constraint ALTER TABLE TBL_TIMESHEET ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID);
alter table kortex.sql add constraint ALTER TABLE TBL_TIMESHEET ADD FOREIGN KEY (INT_TASKID) REFERENCES TBL_TASK (INT_TASKID);
alter table kortex.sql add constraint ALTER TABLE TBL_TRANSACTION ADD CONSTRAINT FK_TRANS_CONTACT FOREIGN KEY (INT_CONTACTID) REFERENCES TBL_CONTACT (INT_CONTACTID);
alter table kortex.sql add constraint ALTER TABLE TBL_TRANSACTION ADD FOREIGN KEY (INT_TTYPEID) REFERENCES TLKP_TTYPE (INT_TTYPEID);
alter table kortex.sql add constraint ALTER TABLE TBL_TRANSACTION ADD FOREIGN KEY (INT_ACCOUNTID) REFERENCES TBL_ACCOUNT (INT_ACCOUNTID);
alter table kortex.sql add constraint ALTER TABLE TBL_TRANSACTION ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID);
alter table kortex.sql add constraint ALTER TABLE TBL_TRANSACTION ADD FOREIGN KEY (INT_CHILDOF) REFERENCES TBL_TRANSACTION (INT_TRANSID);
alter table kortex.sql add constraint ALTER TABLE TBL_TRANSACTION ADD FOREIGN KEY (INT_INVITEMID) REFERENCES TBL_INVITEM (INT_ITEMID);
alter table kortex.sql add constraint ALTER TABLE TBL_TRANSACTION ADD FOREIGN KEY (INT_SERVITEMID) REFERENCES TBL_SERVICEITEM (INT_SERVITEMID);
alter table kortex.sql add constraint ALTER TABLE TBL_XCODE ADD CONSTRAINT FK_TYPE FOREIGN KEY (INT_TYPEID) REFERENCES TLKP_XCODE_TYPE (INT_TYPEID);
alter table kortex.sql add constraint ALTER TABLE TBL_XCODE ADD FOREIGN KEY (INT_LASTEDITOR) REFERENCES TBL_USER (INT_USERID);
alter table kortex.sql add constraint ALTER TABLE TBL_XIMPORTLOG ADD FOREIGN KEY (INT_SESSIONID) REFERENCES TBL_XIMPORT (INT_SESSIONID);
alter table kortex.sql add constraint ALTER TABLE TBL_XIMPORTMAP ADD FOREIGN KEY (INT_SESSIONID) REFERENCES TBL_XIMPORT (INT_SESSIONID);
alter table kortex.sql add constraint ALTER TABLE TBL_XTAGVAL ADD FOREIGN KEY (INT_XTAGID) REFERENCES TBL_XTAG (INT_XTAGID);
alter table kortex.sql add constraint ALTER TABLE TLKP_INVMANUFMODEL ADD FOREIGN KEY (INT_MANUFID) REFERENCES TLKP_INVMANUFACTURER (INT_MANUFID);
alter table kortex.sql add constraint ALTER TABLE TLNK_APPUSER ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID);
alter table kortex.sql add constraint ALTER TABLE TLNK_APPUSER ADD FOREIGN KEY (INT_APPID) REFERENCES TBL_APP (INT_APPID);
alter table kortex.sql add constraint ALTER TABLE TLNK_CONTACTSKILL ADD FOREIGN KEY (INT_SKILLID) REFERENCES TLKP_ERPSKILL (INT_SKILLID);
alter table kortex.sql add constraint ALTER TABLE TLNK_CONTACTSKILL ADD FOREIGN KEY (INT_CONTACTID) REFERENCES TBL_CONTACT (INT_CONTACTID);
alter table kortex.sql add constraint ALTER TABLE TLNK_DOCREGTRANS ADD CONSTRAINT FK_DRT_T FOREIGN KEY (INT_DOCID) REFERENCES TBL_DOCREGISTER (INT_DOCID);
alter table kortex.sql add constraint ALTER TABLE TLNK_INVITEMPRICE ADD CONSTRAINT FK_ITEM_PRICE FOREIGN KEY (INT_ITEMID) REFERENCES TBL_INVITEM (INT_ITEMID);
alter table kortex.sql add constraint ALTER TABLE TLNK_INVOICEITEMS ADD CONSTRAINT FK_TII_TRANSID FOREIGN KEY (INT_TRANSID) REFERENCES TBL_TRANSACTION (INT_TRANSID);
alter table kortex.sql add constraint ALTER TABLE TLNK_ROLEOPTION ADD FOREIGN KEY (INT_ROLEID) REFERENCES TBL_ROLE (INT_ROLEID);
alter table kortex.sql add constraint ALTER TABLE TLNK_ROLEOPTION ADD FOREIGN KEY (INT_OPTIONID) REFERENCES TBL_OPTION (INT_OPTIONID);
alter table kortex.sql add constraint ALTER TABLE TLNK_ROLESECTION ADD FOREIGN KEY (INT_SECTIONID) REFERENCES TBL_SECTION (INT_SECTIONID);
alter table kortex.sql add constraint ALTER TABLE TLNK_ROLESECTION ADD FOREIGN KEY (INT_ROLEID) REFERENCES TBL_ROLE (INT_ROLEID);
alter table kortex.sql add constraint ALTER TABLE TLNK_ROLEXCODE ADD FOREIGN KEY (INT_ROLEID) REFERENCES TBL_ROLE (INT_ROLEID);
alter table kortex.sql add constraint ALTER TABLE TLNK_USERROLE ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID);
alter table kortex.sql add constraint ALTER TABLE TLNK_USERROLE ADD FOREIGN KEY (INT_ROLEID) REFERENCES TBL_ROLE (INT_ROLEID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_ACCOUNT ADD CONSTRAINT FK_ACCTYPE FOREIGN KEY (INT_ACCTYPEID) REFERENCES TLKP_ACCTYPE (INT_ACCTYPEID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_ACCOUNT ADD FOREIGN KEY (INT_OWNERID) REFERENCES TBL_USER (INT_USERID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_ACCOUNT ADD FOREIGN KEY (INT_CHILDOF) REFERENCES TBL_ACCOUNT (INT_ACCOUNTID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_CONTACT ADD FOREIGN KEY (INT_LOCALITY) REFERENCES TLKP_LOCALITY (INT_LOCALITYID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_HISTORY ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_INVITEM ADD FOREIGN KEY (INT_OWNERID) REFERENCES TBL_USER (INT_USERID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_INVITEM ADD FOREIGN KEY (INT_TYPEID) REFERENCES TLKP_INVITEMTYPE (INT_TYPEID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_INVITEM ADD FOREIGN KEY (INT_MODELID INT_MANUFID) REFERENCES TLKP_INVMANUFMODEL (INT_MODELID INT_MANUFID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_OPTION ADD FOREIGN KEY (INT_CHILDOF) REFERENCES TBL_OPTION (INT_OPTIONID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_OPTION ADD FOREIGN KEY (INT_SECTIONID) REFERENCES TBL_SECTION (INT_SECTIONID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_SCHEDULE ADD FOREIGN KEY (INT_TASKID) REFERENCES TBL_TASK (INT_TASKID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_SCHEDULE ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_TASK ADD CONSTRAINT FK_CONTACT FOREIGN KEY (INT_CONTACTID) REFERENCES TBL_CONTACT (INT_CONTACTID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_TASK ADD FOREIGN KEY (INT_CREATEDBY) REFERENCES TBL_USER (INT_USERID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_TASK ADD FOREIGN KEY (INT_CREATEDFOR) REFERENCES TBL_USER (INT_USERID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_TASKALLOC ADD FOREIGN KEY (INT_TASKID) REFERENCES TBL_TASK (INT_TASKID) ON UPDATE CASCADE;
alter table passport_repair.sql add constraint ALTER TABLE TBL_TASKALLOC ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID) ON UPDATE CASCADE;
alter table passport_repair.sql add constraint ALTER TABLE TBL_TASKEVENT ADD FOREIGN KEY (INT_TASKID) REFERENCES TBL_TASK (INT_TASKID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_TASKEVENT ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_TASKNOTES ADD FOREIGN KEY (INT_TASKID) REFERENCES TBL_TASK (INT_TASKID) ON UPDATE CASCADE;
alter table passport_repair.sql add constraint ALTER TABLE TBL_TIMESHEET ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_TIMESHEET ADD FOREIGN KEY (INT_TASKID) REFERENCES TBL_TASK (INT_TASKID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_TRANSACTION ADD CONSTRAINT FK_TRANS_CONTACT FOREIGN KEY (INT_CONTACTID) REFERENCES TBL_CONTACT (INT_CONTACTID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_TRANSACTION ADD FOREIGN KEY (INT_TTYPEID) REFERENCES TLKP_TTYPE (INT_TTYPEID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_TRANSACTION ADD FOREIGN KEY (INT_ACCOUNTID) REFERENCES TBL_ACCOUNT (INT_ACCOUNTID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_TRANSACTION ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_TRANSACTION ADD FOREIGN KEY (INT_CHILDOF) REFERENCES TBL_TRANSACTION (INT_TRANSID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_TRANSACTION ADD FOREIGN KEY (INT_INVITEMID) REFERENCES TBL_INVITEM (INT_ITEMID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_TRANSACTION ADD FOREIGN KEY (INT_SERVITEMID) REFERENCES TBL_SERVICEITEM (INT_SERVITEMID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_XCODE ADD CONSTRAINT FK_TYPE FOREIGN KEY (INT_TYPEID) REFERENCES TLKP_XCODE_TYPE (INT_TYPEID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_XCODE ADD FOREIGN KEY (INT_LASTEDITOR) REFERENCES TBL_USER (INT_USERID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_XIMPORTLOG ADD FOREIGN KEY (INT_SESSIONID) REFERENCES TBL_XIMPORT (INT_SESSIONID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_XIMPORTMAP ADD FOREIGN KEY (INT_SESSIONID) REFERENCES TBL_XIMPORT (INT_SESSIONID);
alter table passport_repair.sql add constraint ALTER TABLE TBL_XTAGVAL ADD FOREIGN KEY (INT_XTAGID) REFERENCES TBL_XTAG (INT_XTAGID);
alter table passport_repair.sql add constraint ALTER TABLE TLKP_INVMANUFMODEL ADD FOREIGN KEY (INT_MANUFID) REFERENCES TLKP_INVMANUFACTURER (INT_MANUFID);
alter table passport_repair.sql add constraint ALTER TABLE TLNK_APPUSER ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID);
alter table passport_repair.sql add constraint ALTER TABLE TLNK_APPUSER ADD FOREIGN KEY (INT_APPID) REFERENCES TBL_APP (INT_APPID);
alter table passport_repair.sql add constraint ALTER TABLE TLNK_CONTACTSKILL ADD FOREIGN KEY (INT_SKILLID) REFERENCES TLKP_ERPSKILL (INT_SKILLID);
alter table passport_repair.sql add constraint ALTER TABLE TLNK_CONTACTSKILL ADD FOREIGN KEY (INT_CONTACTID) REFERENCES TBL_CONTACT (INT_CONTACTID);
alter table passport_repair.sql add constraint ALTER TABLE TLNK_DOCREGTRANS ADD CONSTRAINT FK_DRT_T FOREIGN KEY (INT_DOCID) REFERENCES TBL_DOCREGISTER (INT_DOCID);
alter table passport_repair.sql add constraint ALTER TABLE TLNK_INVITEMPRICE ADD CONSTRAINT FK_ITEM_PRICE FOREIGN KEY (INT_ITEMID) REFERENCES TBL_INVITEM (INT_ITEMID);
alter table passport_repair.sql add constraint ALTER TABLE TLNK_INVOICEITEMS ADD CONSTRAINT FK_TII_TRANSID FOREIGN KEY (INT_TRANSID) REFERENCES TBL_TRANSACTION (INT_TRANSID);
alter table passport_repair.sql add constraint ALTER TABLE TLNK_ROLEOPTION ADD FOREIGN KEY (INT_ROLEID) REFERENCES TBL_ROLE (INT_ROLEID);
alter table passport_repair.sql add constraint ALTER TABLE TLNK_ROLEOPTION ADD FOREIGN KEY (INT_OPTIONID) REFERENCES TBL_OPTION (INT_OPTIONID);
alter table passport_repair.sql add constraint ALTER TABLE TLNK_ROLESECTION ADD FOREIGN KEY (INT_SECTIONID) REFERENCES TBL_SECTION (INT_SECTIONID);
alter table passport_repair.sql add constraint ALTER TABLE TLNK_ROLESECTION ADD FOREIGN KEY (INT_ROLEID) REFERENCES TBL_ROLE (INT_ROLEID);
alter table passport_repair.sql add constraint ALTER TABLE TLNK_ROLEXCODE ADD FOREIGN KEY (INT_ROLEID) REFERENCES TBL_ROLE (INT_ROLEID);
alter table passport_repair.sql add constraint ALTER TABLE TLNK_USERROLE ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER (INT_USERID);
alter table passport_repair.sql add constraint ALTER TABLE TLNK_USERROLE ADD FOREIGN KEY (INT_ROLEID) REFERENCES TBL_ROLE (INT_ROLEID);
alter table tbl_account add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact(int_contactid);
alter table tbl_account add constraint FOREIGN KEY(int_childof) REFERENCES tbl_account (int_accountid);
alter table tbl_account add constraint FOREIGN KEY(lkp_acctypeid) REFERENCES tlkp_choices (int_choiceid);
alter table tbl_campaign add constraint FOREIGN KEY(int_featureid) REFERENCES tbl_feature(int_featureid);
alter table tbl_campscopegroups add constraint FOREIGN KEY(int_campaignid) REFERENCES tbl_campaign(int_campaignid);
alter table tbl_campscopegroups add constraint FOREIGN KEY(int_contactgroupid) REFERENCES tlkp_contactgroup(int_contactgroupid);
alter table tbl_campscopelocality add constraint FOREIGN KEY(int_campaignid) REFERENCES tbl_campaign(int_campaignid);
alter table tbl_campscopelocality add constraint FOREIGN KEY(int_localityid) REFERENCES tlkp_locality(int_localityid);
alter table tbl_campscopetypes add constraint FOREIGN KEY(int_campaignid) REFERENCES tbl_campaign(int_campaignid);
alter table tbl_campscopetypes add constraint FOREIGN KEY(int_contacttypeid) REFERENCES tlkp_contacttype(int_contacttypeid);
alter table tbl_contactchain add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact(int_contactid);
alter table tbl_contactchain add constraint FOREIGN KEY(int_childof) REFERENCES tbl_contact(int_contactid);
alter table tbl_contactreps add constraint FOREIGN KEY(int_userid) REFERENCES tbl_user(int_userid);
alter table tbl_contactreps add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact(int_contactid);
alter table tbl_contact add constraint FOREIGN KEY(int_locality) REFERENCES tlkp_locality(int_localityid);
alter table tbl_contact add constraint FOREIGN KEY(int_positionid) REFERENCES tlkp_erpposition(int_positionid);
alter table tbl_costcode add constraint FOREIGN KEY(int_ownerid) REFERENCES tbl_user(int_userid);
alter table tbl_costcode add constraint FOREIGN KEY(int_childof) REFERENCES tbl_costcode (int_costcodeid);
alter table tbl_feature add constraint FOREIGN KEY(INT_FEATURETYPEID) REFERENCES tlkp_featuretype(int_featuretypeid);
alter table tbl_file.sql add constraint alter table tbl_file add constraint fk_file_contact FOREIGN KEY (int_userid) references tbl_contact (int_contactid);
alter table tbl_folderaccess add constraint FOREIGN KEY(int_roleid) REFERENCES tbl_role(int_roleid);
alter table tbl_incident add constraint FOREIGN KEY(int_ownerid) REFERENCES tbl_user(int_userid);
alter table tbl_invitem add constraint FOREIGN KEY(int_ownerid) REFERENCES tbl_user(int_userid);
alter table tbl_invitem add constraint FOREIGN KEY(int_typeid) REFERENCES tlkp_invitemtype(int_typeid);
alter table tbl_invitem add constraint FOREIGN KEY(int_modelid int_manufid) REFERENCES tlkp_invmanufmodel (int_modelid int_manufid);
alter table tbl_invsiteitemqty add constraint FOREIGN KEY(int_itemid) REFERENCES tbl_invitem (int_itemid);
alter table tbl_invsiteitemqty add constraint FOREIGN KEY(int_siteid) REFERENCES tbl_invsite (int_itemid);
alter table tbl_mailaccount add constraint FOREIGN KEY(int_tagid) REFERENCES tbl_mailaccounttag(int_tagid);
alter table tbl_mailaccount add constraint FOREIGN KEY(int_userid) REFERENCES tbl_user(int_userid);
alter table tbl_mailfile add constraint FOREIGN KEY(int_accountid) REFERENCES tbl_mailaccount(int_accountid);
alter table tbl_mailfile add constraint FOREIGN KEY(int_tagid) REFERENCES tlkp_mailaccounttags(int_tagid);
alter table tbl_message add constraint FOREIGN KEY(int_userid) REFERENCES tbl_user(int_userid);
alter table tbl_pagenote add constraint FOREIGN KEY(int_pageid) REFERENCES tbl_page(int_pageid);
alter table tbl_page add constraint FOREIGN KEY(int_sectionid) REFERENCES tbl_section (int_sectionid);
alter table tbl_page add constraint FOREIGN KEY(int_templateid) REFERENCES tbl_template (int_templateid);
alter table tbl_page add constraint FOREIGN KEY(int_childof) REFERENCES tbl_page(int_pageid);
alter table tbl_pagetags add constraint FOREIGN KEY(int_pageid) REFERENCES tbl_page(int_pageid);
alter table tbl_pagetags add constraint FOREIGN KEY(int_tagid) REFERENCES tbl_tags(int_tagid);
alter table tbl_processchain add constraint FOREIGN KEY (int_chainid) references tbl_processchain (int_chainid);
alter table tbl_processchain add constraint FOREIGN KEY (int_childof) references tbl_processlink (int_linkid);
alter table tbl_processchain add constraint FOREIGN KEY (int_linktype) references tlkp_linktype (int_typeid);
alter table tbl_project add constraint FOREIGN KEY(int_childofid) REFERENCES tbl_project(int_projectid);
alter table tbl_project add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact(int_contactid);
alter table tbl_project add constraint FOREIGN KEY(int_priorityid) REFERENCES tlkp_priority(int_priorityid);
alter table tbl_projteam add constraint FOREIGN KEY(int_projectid) REFERENCES tbl_project(int_projectid);
alter table tbl_projteam add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact(int_contactid);
alter table tbl_publication add constraint FOREIGN KEY(int_pubtype) REFERENCES tlkp_pubtype(int_pubtypeid);
alter table tbl_schedule add constraint FOREIGN KEY(int_taskid) REFERENCES tbl_task(int_taskid);
alter table tbl_schedule add constraint FOREIGN KEY(int_userid) REFERENCES tbl_user(int_userid);
alter table tbl_taskevent add constraint FOREIGN KEY(int_taskid) REFERENCES tbl_task(int_taskid);
alter table tbl_taskevent add constraint FOREIGN KEY(int_userid) REFERENCES tbl_user(int_userid);
alter table tbl_task add constraint FOREIGN KEY(int_createdby) REFERENCES tbl_user(int_userid);
alter table tbl_task add constraint FOREIGN KEY(int_createdfor) REFERENCES tbl_user(int_userid);
alter table tbl_task add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact(int_contactid);
alter table tbl_task add constraint FOREIGN KEY(int_projectid) REFERENCES tbl_project(int_projectid);
alter table tbl_task add constraint FOREIGN KEY(int_priorityid) REFERENCES tlkp_listchoices(int_listid);
alter table tbl_task add constraint FOREIGN KEY(int_previoustaskid) REFERENCES tbl_task(int_taskid);
alter table tbl_task add constraint FOREIGN KEY(int_previousflagid) REFERENCES tlkp_listchoices(int_listid);
alter table tbl_templatetags add constraint FOREIGN KEY(int_templateid) REFERENCES tbl_template(int_templateid);
alter table tbl_templatetags add constraint FOREIGN KEY(int_tagid) REFERENCES tbl_tags(int_tagid);
alter table tbl_timesheet.sql add constraint ALTER TABLE TBL_TIMESHEET ADD FOREIGN KEY (INT_USERID) REFERENCES TBL_USER;
alter table tbl_timesheet.sql add constraint ALTER TABLE TBL_TIMESHEET ADD FOREIGN KEY (INT_TASKID) REFERENCES TBL_TASK;
alter table tbl_transaction add constraint FOREIGN KEY(int_ttypeid) REFERENCES tlkp_ttype(int_ttypeid);
alter table tbl_transaction add constraint FOREIGN KEY(int_accountid) REFERENCES tbl_account(int_accountid);
alter table tbl_transaction add constraint FOREIGN KEY(int_costcodeid) REFERENCES tbl_costcode(int_costcodeid);
alter table tbl_transaction add constraint FOREIGN KEY(int_projectid) REFERENCES tbl_project(int_projectid);
alter table tbl_transaction add constraint FOREIGN KEY(int_userid) REFERENCES tbl_user(int_userid);
alter table tbl_transaction add constraint FOREIGN KEY(int_childof) REFERENCES tbl_transaction(int_transid);
alter table tbl_transaction add constraint FOREIGN KEY(int_invitemid) REFERENCES tbl_invitem(int_itemid);
alter table tbl_transaction add constraint FOREIGN KEY(int_servitemid) REFERENCES tbl_serviceitem(int_servitemid);
alter table tbl_transaction add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact(int_contactid);
alter table tbl_transext add constraint FOREIGN KEY(int_typeid) REFERENCES tlkp_transtype(int_typeid);
alter table tbl_transext add constraint FOREIGN KEY(int_userid) REFERENCES tbl_user(int_userid);
alter table tbl_transext add constraint FOREIGN KEY(int_itemid) REFERENCES tbl_invitem(int_itemid);
alter table tbl_transext add constraint FOREIGN KEY(int_childof) REFERENCES tbl_transaction(int_transid);
alter table tblx_contact add constraint FOREIGN KEY(int_tagid) REFERENCES tlkp_exttag (int_tagid);
alter table tblx_contact add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact(int_contactid);
alter table tlkp_erpposition add constraint FOREIGN KEY(int_childof) references tlkp_erpposition(int_positionid);
alter table tlkp_erpposition.sql add constraint alter table tlkp_erpposition add constraint fk_approvelev foreign key (int_approveid) references tlkp_finapprovelevels(int_approveid);
alter table tlkp_invcategory add constraint FOREIGN KEY(int_childof) REFERENCES tlkp_invcategory (int_catid);
alter table tlkp_invmanufmodel add constraint FOREIGN KEY(int_manufid) REFERENCES tlkp_invmanufacturer(int_manufid);
alter table tlnk_contactgroup add constraint FOREIGN KEY(int_contactgroupid) REFERENCES tlkp_contactgroup(int_contactgroupid);
alter table tlnk_contactgroup add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact(int_contactid);
alter table tlnk_contactskill add constraint FOREIGN KEY(int_skillid) REFERENCES tlkp_erpskill(int_skillid);
alter table tlnk_contactskill add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact(int_contactid);
alter table tlnk_contacttype add constraint FOREIGN KEY(int_contacttypeid) REFERENCES tlkp_contacttype(int_contacttypeid);
alter table tlnk_contacttype add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact(int_contactid);
alter table tlnk_cont_camp_status add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact(int_contactid);
alter table tlnk_cont_camp_status add constraint FOREIGN KEY(int_campaignid) REFERENCES tbl_campaign(int_campaignid);
alter table tlnk_contfile add constraint FOREIGN KEY(int_fileid) REFERENCES tbl_file(int_fileid);
alter table tlnk_contfile add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact(int_contactid);
alter table tlnk_filegroup add constraint FOREIGN KEY (int_groupid) REFERENCES tlkp_filegroup (int_groupid);
alter table tlnk_filegroup add constraint FOREIGN KEY (int_fileid) REFERENCES tbl_file (int_fileid);
alter table tlnk_incidentdata.sql add constraint * Added tracking and fixed foreign keys;
alter table tlnk_incidentdata add constraint FOREIGN KEY(int_incidentid) REFERENCES tbl_incident(int_incidentid);
alter table tlnk_incidentdata add constraint FOREIGN KEY(int_listid) REFERENCES tlkp_listitems(int_listid);
alter table tlnk_invitemcat add constraint FOREIGN KEY(int_catid) REFERENCES tlkp_invcategory (int_catid);
alter table tlnk_invitemcat add constraint FOREIGN KEY(int_itemid) REFERENCES tbl_invitem (int_itemid);
alter table tlnk_invitemfile add constraint FOREIGN KEY(int_fileid) REFERENCES tbl_file(int_fileid);
alter table tlnk_invitemfile add constraint FOREIGN KEY(int_itemid) REFERENCES tbl_invitem(int_itemid);
alter table tlnk_invitemprice add constraint FOREIGN KEY(int_qtyid) REFERENCES tlkp_invqty (int_qtyid);
alter table tlnk_invitemprice add constraint FOREIGN KEY(int_unitid) REFERENCES tlkp_invunit (int_unitid);
alter table tlnk_invitemregion add constraint FOREIGN KEY(int_regionid) REFERENCES tlkp_region (int_regionid);
alter table tlnk_invitemregion add constraint FOREIGN KEY(int_itemid) REFERENCES tbl_invitem (int_itemid);
alter table tlnk_invitemtagvals add constraint FOREIGN KEY(int_itemid) REFERENCES tbl_invitem(int_itemid);
alter table tlnk_invitemtagvals add constraint FOREIGN KEY(int_tagid) REFERENCES tlkp_invitemtag(int_tagid);
alter table tlnk_mailaccountvalues add constraint FOREIGN KEY(int_accountid) REFERENCES tbl_mailaccount(int_accountid);
alter table tlnk_mailaccountvalues add constraint FOREIGN KEY(int_tagid) REFERENCES tlkp_mailaccounttags(int_tagid);
alter table tlnk_maildelay add constraint FOREIGN KEY(int_accountid) REFERENCES tbl_mailaccount(int_accountid);
alter table tlnk_puborders add constraint FOREIGN KEY(int_pubid) REFERENCES tbl_publication(int_pubid);
alter table tlnk_puborders add constraint FOREIGN KEY(int_contactid) REFERENCES tbl_contact(int_contactid);
alter table tlnk_puborders add constraint FOREIGN KEY(int_ordertypeid) REFERENCES tlkp_ordertype(int_ordertypeid);
alter table tlnk_puborders add constraint FOREIGN KEY(int_flagtypeid) REFERENCES tlkp_orderflagtype(int_flagtypeid);
alter table tlnk_taskalloc add constraint FOREIGN KEY(int_taskid) references tbl_task(int_taskid) ON UPDATE CASCADE;
alter table tlnk_taskalloc add constraint FOREIGN KEY(int_userid) references tbl_user(int_userid) ON UPDATE CASCADE;