-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate-ss-database.sql
More file actions
787 lines (687 loc) · 25.2 KB
/
Copy pathcreate-ss-database.sql
File metadata and controls
787 lines (687 loc) · 25.2 KB
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
/*==============================================================*/
/* DBMS name: Microsoft SQL Server 2005 */
/* Created on: 5/16/2025 11:45:25 PM */
/*==============================================================*/
CREATE DATABASE SS;
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('ADDRESS') and o.name = 'FK_ADDRESS_RESIDES_INSURANC')
alter table ADDRESS
drop constraint FK_ADDRESS_RESIDES_INSURANC
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('CAR') and o.name = 'FK_CAR_COVERS_INSURANC')
alter table CAR
drop constraint FK_CAR_COVERS_INSURANC
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('CAR_ACCIDENT') and o.name = 'FK_CAR_ACCI_INVOLVES_CAR')
alter table CAR_ACCIDENT
drop constraint FK_CAR_ACCI_INVOLVES_CAR
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('CAR_ACCIDENT') and o.name = 'FK_CAR_ACCI_RELATIONS_MONTHLY_')
alter table CAR_ACCIDENT
drop constraint FK_CAR_ACCI_RELATIONS_MONTHLY_
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('COLOR') and o.name = 'FK_COLOR_HAS_CAR')
alter table COLOR
drop constraint FK_COLOR_HAS_CAR
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('COMMITS') and o.name = 'FK_COMMITS_COMMITS_CUSTOMER')
alter table COMMITS
drop constraint FK_COMMITS_COMMITS_CUSTOMER
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('COMMITS') and o.name = 'FK_COMMITS_COMMITS2_CAR_ACCI')
alter table COMMITS
drop constraint FK_COMMITS_COMMITS2_CAR_ACCI
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('EMPLOYEE') and o.name = 'FK_EMPLOYEE_RELATINSH_EMPLOYEE')
alter table EMPLOYEE
drop constraint FK_EMPLOYEE_RELATINSH_EMPLOYEE
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('INSURANCE_POLICY') and o.name = 'FK_INSURANC_HASSSSS_CUSTOMER')
alter table INSURANCE_POLICY
drop constraint FK_INSURANC_HASSSSS_CUSTOMER
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('INSURANCE_POLICY') and o.name = 'FK_INSURANC_PROVIDES_INSURANC')
alter table INSURANCE_POLICY
drop constraint FK_INSURANC_PROVIDES_INSURANC
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('MONTHLY_REPORT') and o.name = 'FK_MONTHLY__WRITES_EMPLOYEE')
alter table MONTHLY_REPORT
drop constraint FK_MONTHLY__WRITES_EMPLOYEE
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('OWNSS') and o.name = 'FK_OWNSS_OWNSS_CUSTOMER')
alter table OWNSS
drop constraint FK_OWNSS_OWNSS_CUSTOMER
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('OWNSS') and o.name = 'FK_OWNSS_OWNSS2_CAR')
alter table OWNSS
drop constraint FK_OWNSS_OWNSS2_CAR
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('PHONE_NUMBER') and o.name = 'FK_PHONE_NU_ACQUIRES_EMPLOYEE')
alter table PHONE_NUMBER
drop constraint FK_PHONE_NU_ACQUIRES_EMPLOYEE
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('PHONE_NUMBER2') and o.name = 'FK_PHONE_NU_OWNS_CUSTOMER')
alter table PHONE_NUMBER2
drop constraint FK_PHONE_NU_OWNS_CUSTOMER
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('PHONE_NUMBER3') and o.name = 'FK_PHONE_NU_HOLDS_INSURANC')
alter table PHONE_NUMBER3
drop constraint FK_PHONE_NU_HOLDS_INSURANC
go
if exists (select 1
from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
where r.fkeyid = object_id('POLICYCOVERAGEITEM') and o.name = 'FK_POLICYCO_INCLUDES_INSURANC')
alter table POLICYCOVERAGEITEM
drop constraint FK_POLICYCO_INCLUDES_INSURANC
go
if exists (select 1
from sysindexes
where id = object_id('ADDRESS')
and name = 'RESIDES_FK'
and indid > 0
and indid < 255)
drop index ADDRESS.RESIDES_FK
go
if exists (select 1
from sysobjects
where id = object_id('ADDRESS')
and type = 'U')
drop table ADDRESS
go
if exists (select 1
from sysindexes
where id = object_id('CAR')
and name = 'COVERS_FK'
and indid > 0
and indid < 255)
drop index CAR.COVERS_FK
go
if exists (select 1
from sysobjects
where id = object_id('CAR')
and type = 'U')
drop table CAR
go
if exists (select 1
from sysindexes
where id = object_id('CAR_ACCIDENT')
and name = 'RELATIONSHIP_3_FK'
and indid > 0
and indid < 255)
drop index CAR_ACCIDENT.RELATIONSHIP_3_FK
go
if exists (select 1
from sysindexes
where id = object_id('CAR_ACCIDENT')
and name = 'INVOLVES_FK'
and indid > 0
and indid < 255)
drop index CAR_ACCIDENT.INVOLVES_FK
go
if exists (select 1
from sysobjects
where id = object_id('CAR_ACCIDENT')
and type = 'U')
drop table CAR_ACCIDENT
go
if exists (select 1
from sysindexes
where id = object_id('COLOR')
and name = 'HAS_FK'
and indid > 0
and indid < 255)
drop index COLOR.HAS_FK
go
if exists (select 1
from sysobjects
where id = object_id('COLOR')
and type = 'U')
drop table COLOR
go
if exists (select 1
from sysindexes
where id = object_id('COMMITS')
and name = 'COMMITS2_FK'
and indid > 0
and indid < 255)
drop index COMMITS.COMMITS2_FK
go
if exists (select 1
from sysindexes
where id = object_id('COMMITS')
and name = 'COMMITS_FK'
and indid > 0
and indid < 255)
drop index COMMITS.COMMITS_FK
go
if exists (select 1
from sysobjects
where id = object_id('COMMITS')
and type = 'U')
drop table COMMITS
go
if exists (select 1
from sysobjects
where id = object_id('CUSTOMER')
and type = 'U')
drop table CUSTOMER
go
if exists (select 1
from sysindexes
where id = object_id('EMPLOYEE')
and name = 'RELATINSHIP_6_FK'
and indid > 0
and indid < 255)
drop index EMPLOYEE.RELATINSHIP_6_FK
go
if exists (select 1
from sysobjects
where id = object_id('EMPLOYEE')
and type = 'U')
drop table EMPLOYEE
go
if exists (select 1
from sysobjects
where id = object_id('INSURANCEPROVIDER')
and type = 'U')
drop table INSURANCEPROVIDER
go
if exists (select 1
from sysindexes
where id = object_id('INSURANCE_POLICY')
and name = 'PROVIDES_FK'
and indid > 0
and indid < 255)
drop index INSURANCE_POLICY.PROVIDES_FK
go
if exists (select 1
from sysindexes
where id = object_id('INSURANCE_POLICY')
and name = 'HASSSSS_FK'
and indid > 0
and indid < 255)
drop index INSURANCE_POLICY.HASSSSS_FK
go
if exists (select 1
from sysobjects
where id = object_id('INSURANCE_POLICY')
and type = 'U')
drop table INSURANCE_POLICY
go
if exists (select 1
from sysindexes
where id = object_id('MONTHLY_REPORT')
and name = 'WRITES_FK'
and indid > 0
and indid < 255)
drop index MONTHLY_REPORT.WRITES_FK
go
if exists (select 1
from sysobjects
where id = object_id('MONTHLY_REPORT')
and type = 'U')
drop table MONTHLY_REPORT
go
if exists (select 1
from sysindexes
where id = object_id('OWNSS')
and name = 'OWNSS2_FK'
and indid > 0
and indid < 255)
drop index OWNSS.OWNSS2_FK
go
if exists (select 1
from sysindexes
where id = object_id('OWNSS')
and name = 'OWNSS_FK'
and indid > 0
and indid < 255)
drop index OWNSS.OWNSS_FK
go
if exists (select 1
from sysobjects
where id = object_id('OWNSS')
and type = 'U')
drop table OWNSS
go
if exists (select 1
from sysindexes
where id = object_id('PHONE_NUMBER')
and name = 'ACQUIRES_FK'
and indid > 0
and indid < 255)
drop index PHONE_NUMBER.ACQUIRES_FK
go
if exists (select 1
from sysobjects
where id = object_id('PHONE_NUMBER')
and type = 'U')
drop table PHONE_NUMBER
go
if exists (select 1
from sysindexes
where id = object_id('PHONE_NUMBER2')
and name = 'OWNS_FK'
and indid > 0
and indid < 255)
drop index PHONE_NUMBER2.OWNS_FK
go
if exists (select 1
from sysobjects
where id = object_id('PHONE_NUMBER2')
and type = 'U')
drop table PHONE_NUMBER2
go
if exists (select 1
from sysindexes
where id = object_id('PHONE_NUMBER3')
and name = 'HOLDS_FK'
and indid > 0
and indid < 255)
drop index PHONE_NUMBER3.HOLDS_FK
go
if exists (select 1
from sysobjects
where id = object_id('PHONE_NUMBER3')
and type = 'U')
drop table PHONE_NUMBER3
go
if exists (select 1
from sysindexes
where id = object_id('POLICYCOVERAGEITEM')
and name = 'INCLUDES_FK'
and indid > 0
and indid < 255)
drop index POLICYCOVERAGEITEM.INCLUDES_FK
go
if exists (select 1
from sysobjects
where id = object_id('POLICYCOVERAGEITEM')
and type = 'U')
drop table POLICYCOVERAGEITEM
go
/*==============================================================*/
/* Table: ADDRESS */
/*==============================================================*/
create table ADDRESS (
ADDDDDD varchar(100) not null,
PROVIDERIFD int not null,
PROVIDERID int not null,
constraint PK_ADDRESS primary key nonclustered (ADDDDDD, PROVIDERIFD)
)
go
/*==============================================================*/
/* Index: RESIDES_FK */
/*==============================================================*/
create index RESIDES_FK on ADDRESS (
PROVIDERID ASC
)
go
/*==============================================================*/
/* Table: CAR */
/*==============================================================*/
create table CAR (
CARID int not null,
POLICYID int not null,
MODEL varchar(20) null,
MANIFACTURER varchar(30) null,
YEAR int null,
LICENSE_PLATE varchar(10) null,
constraint PK_CAR primary key nonclustered (CARID)
)
go
/*==============================================================*/
/* Index: COVERS_FK */
/*==============================================================*/
create index COVERS_FK on CAR (
POLICYID ASC
)
go
/*==============================================================*/
/* Table: CAR_ACCIDENT */
/*==============================================================*/
create table CAR_ACCIDENT (
SEVERITY int null,
MONTH int null,
YEAR int null,
ACCIDENT_ID int not null,
REPORTID int not null,
CARID int not null,
CITY varchar(25) null,
STATE varchar(25) null,
STREET varchar(25) null,
constraint PK_CAR_ACCIDENT primary key nonclustered (ACCIDENT_ID)
)
go
/*==============================================================*/
/* Index: INVOLVES_FK */
/*==============================================================*/
create index INVOLVES_FK on CAR_ACCIDENT (
CARID ASC
)
go
/*==============================================================*/
/* Index: RELATIONSHIP_3_FK */
/*==============================================================*/
create index RELATIONSHIP_3_FK on CAR_ACCIDENT (
REPORTID ASC
)
go
/*==============================================================*/
/* Table: COLOR */
/*==============================================================*/
create table COLOR (
COLOR varchar(15) not null,
CARID int null,
constraint PK_COLOR primary key nonclustered (COLOR)
)
go
/*==============================================================*/
/* Index: HAS_FK */
/*==============================================================*/
create index HAS_FK on COLOR (
CARID ASC
)
go
/*==============================================================*/
/* Table: COMMITS */
/*==============================================================*/
create table COMMITS (
CUSTOMERID int not null,
ACCIDENT_ID int not null,
constraint PK_COMMITS primary key (CUSTOMERID, ACCIDENT_ID)
)
go
/*==============================================================*/
/* Index: COMMITS_FK */
/*==============================================================*/
create index COMMITS_FK on COMMITS (
CUSTOMERID ASC
)
go
/*==============================================================*/
/* Index: COMMITS2_FK */
/*==============================================================*/
create index COMMITS2_FK on COMMITS (
ACCIDENT_ID ASC
)
go
/*==============================================================*/
/* Table: CUSTOMER */
/*==============================================================*/
create table CUSTOMER (
CUSTOMERID int not null,
FIRSTNAME varchar(20) not null,
LASTNAME varchar(20) not null,
EMAIL varchar(40) not null,
CITY varchar(25) not null,
STATE varchar(25) not null,
STREET varchar(25) not null,
DRIVERLICENSENO int not null,
constraint PK_CUSTOMER primary key nonclustered (CUSTOMERID)
)
go
/*==============================================================*/
/* Table: EMPLOYEE */
/*==============================================================*/
create table EMPLOYEE (
EMPLOYEEID int not null,
EMP_EMPLOYEEID int null,
FIRST_NAME varchar(20) null,
LAST_NAME varchar(20) null,
EMAIL varchar(40) null,
SALARY int null,
constraint PK_EMPLOYEE primary key nonclustered (EMPLOYEEID)
)
go
/*==============================================================*/
/* Index: RELATINSHIP_6_FK */
/*==============================================================*/
create index RELATINSHIP_6_FK on EMPLOYEE (
EMP_EMPLOYEEID ASC
)
go
/*==============================================================*/
/* Table: INSURANCEPROVIDER */
/*==============================================================*/
create table INSURANCEPROVIDER (
PROVIDERID int not null,
PROVIDERNAME varchar(40) not null,
constraint PK_INSURANCEPROVIDER primary key nonclustered (PROVIDERID)
)
go
/*==============================================================*/
/* Table: INSURANCE_POLICY */
/*==============================================================*/
create table INSURANCE_POLICY (
POLICYID int not null,
CUSTOMERID int not null,
PROVIDERID int not null,
"PLAN" varchar(20) not null,
STARTDATE datetime not null,
ENDDATE datetime not null,
POLICYNUMBER int not null,
constraint PK_INSURANCE_POLICY primary key nonclustered (POLICYID)
)
go
/*==============================================================*/
/* Index: HASSSSS_FK */
/*==============================================================*/
create index HASSSSS_FK on INSURANCE_POLICY (
CUSTOMERID ASC
)
go
/*==============================================================*/
/* Index: PROVIDES_FK */
/*==============================================================*/
create index PROVIDES_FK on INSURANCE_POLICY (
PROVIDERID ASC
)
go
/*==============================================================*/
/* Table: MONTHLY_REPORT */
/*==============================================================*/
create table MONTHLY_REPORT (
REPORTID int not null,
EMPLOYEEID int not null,
MONTH int null,
YEAR int null,
TOTALACCIDENTS int null,
constraint PK_MONTHLY_REPORT primary key nonclustered (REPORTID)
)
go
/*==============================================================*/
/* Index: WRITES_FK */
/*==============================================================*/
create index WRITES_FK on MONTHLY_REPORT (
EMPLOYEEID ASC
)
go
/*==============================================================*/
/* Table: OWNSS */
/*==============================================================*/
create table OWNSS (
CUSTOMERID int not null,
CARID int not null,
constraint PK_OWNSS primary key (CUSTOMERID, CARID)
)
go
/*==============================================================*/
/* Index: OWNSS_FK */
/*==============================================================*/
create index OWNSS_FK on OWNSS (
CUSTOMERID ASC
)
go
/*==============================================================*/
/* Index: OWNSS2_FK */
/*==============================================================*/
create index OWNSS2_FK on OWNSS (
CARID ASC
)
go
/*==============================================================*/
/* Table: PHONE_NUMBER */
/*==============================================================*/
create table PHONE_NUMBER (
PHONE_NUMBER varchar(11) not null,
EMPID int not null,
EMPLOYEEID int not null,
constraint PK_PHONE_NUMBER primary key nonclustered (PHONE_NUMBER, EMPID)
)
go
/*==============================================================*/
/* Index: ACQUIRES_FK */
/*==============================================================*/
create index ACQUIRES_FK on PHONE_NUMBER (
EMPLOYEEID ASC
)
go
/*==============================================================*/
/* Table: PHONE_NUMBER2 */
/*==============================================================*/
create table PHONE_NUMBER2 (
PHONE_NUMBER2 varchar(11) not null,
CUSTID int not null,
CUSTOMERID int not null,
constraint PK_PHONE_NUMBER2 primary key nonclustered (PHONE_NUMBER2, CUSTID)
)
go
/*==============================================================*/
/* Index: OWNS_FK */
/*==============================================================*/
create index OWNS_FK on PHONE_NUMBER2 (
CUSTOMERID ASC
)
go
/*==============================================================*/
/* Table: PHONE_NUMBER3 */
/*==============================================================*/
create table PHONE_NUMBER3 (
PHONE_NUMBER3 varchar(11) not null,
PROVIDERID int not null,
constraint PK_PHONE_NUMBER3 primary key nonclustered (PHONE_NUMBER3)
)
go
/*==============================================================*/
/* Index: HOLDS_FK */
/*==============================================================*/
create index HOLDS_FK on PHONE_NUMBER3 (
PROVIDERID ASC
)
go
/*==============================================================*/
/* Table: POLICYCOVERAGEITEM */
/*==============================================================*/
create table POLICYCOVERAGEITEM (
POLICYID int not null,
COVERAGEAMOUNT varchar(40) not null,
COVERAGETYPE varchar(40) not null
)
go
/*==============================================================*/
/* Index: INCLUDES_FK */
/*==============================================================*/
create index INCLUDES_FK on POLICYCOVERAGEITEM (
POLICYID ASC
)
go
alter table ADDRESS
add constraint FK_ADDRESS_RESIDES_INSURANC foreign key (PROVIDERID)
references INSURANCEPROVIDER (PROVIDERID)
go
alter table CAR
add constraint FK_CAR_COVERS_INSURANC foreign key (POLICYID)
references INSURANCE_POLICY (POLICYID)
go
alter table CAR_ACCIDENT
add constraint FK_CAR_ACCI_INVOLVES_CAR foreign key (CARID)
references CAR (CARID)
go
alter table CAR_ACCIDENT
add constraint FK_CAR_ACCI_RELATIONS_MONTHLY_ foreign key (REPORTID)
references MONTHLY_REPORT (REPORTID)
go
alter table COLOR
add constraint FK_COLOR_HAS_CAR foreign key (CARID)
references CAR (CARID)
go
alter table COMMITS
add constraint FK_COMMITS_COMMITS_CUSTOMER foreign key (CUSTOMERID)
references CUSTOMER (CUSTOMERID)
go
alter table COMMITS
add constraint FK_COMMITS_COMMITS2_CAR_ACCI foreign key (ACCIDENT_ID)
references CAR_ACCIDENT (ACCIDENT_ID)
go
alter table EMPLOYEE
add constraint FK_EMPLOYEE_RELATINSH_EMPLOYEE foreign key (EMP_EMPLOYEEID)
references EMPLOYEE (EMPLOYEEID)
go
alter table INSURANCE_POLICY
add constraint FK_INSURANC_HASSSSS_CUSTOMER foreign key (CUSTOMERID)
references CUSTOMER (CUSTOMERID)
go
alter table INSURANCE_POLICY
add constraint FK_INSURANC_PROVIDES_INSURANC foreign key (PROVIDERID)
references INSURANCEPROVIDER (PROVIDERID)
go
alter table MONTHLY_REPORT
add constraint FK_MONTHLY__WRITES_EMPLOYEE foreign key (EMPLOYEEID)
references EMPLOYEE (EMPLOYEEID)
go
alter table OWNSS
add constraint FK_OWNSS_OWNSS_CUSTOMER foreign key (CUSTOMERID)
references CUSTOMER (CUSTOMERID)
go
alter table OWNSS
add constraint FK_OWNSS_OWNSS2_CAR foreign key (CARID)
references CAR (CARID)
go
alter table PHONE_NUMBER
add constraint FK_PHONE_NU_ACQUIRES_EMPLOYEE foreign key (EMPLOYEEID)
references EMPLOYEE (EMPLOYEEID)
go
alter table PHONE_NUMBER2
add constraint FK_PHONE_NU_OWNS_CUSTOMER foreign key (CUSTOMERID)
references CUSTOMER (CUSTOMERID)
go
alter table PHONE_NUMBER3
add constraint FK_PHONE_NU_HOLDS_INSURANC foreign key (PROVIDERID)
references INSURANCEPROVIDER (PROVIDERID)
go
alter table POLICYCOVERAGEITEM
add constraint FK_POLICYCO_INCLUDES_INSURANC foreign key (POLICYID)
references INSURANCE_POLICY (POLICYID)
go