-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_tables.sql
100 lines (82 loc) · 2.58 KB
/
create_tables.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
CREATE TABLE rbi_series (
id int NOT NULL AUTO_INCREMENT,
name varchar(255),
sku varchar(255),
description varchar(65000),
PRIMARY KEY (id)
);
CREATE TABLE rbi_event (
id int NOT NULL AUTO_INCREMENT,
series_id int NOT NULL,
name varchar(255),
start_time time(6),
end_time time(6),
date DATE,
address_1 varchar(255),
address_2 varchar(255),
address_city varchar(255),
address_state varchar(255),
address_zip varchar(255),
address_country varchar(255),
PRIMARY KEY (id),
FOREIGN KEY (series_id) REFERENCES rbi_series(id)
);
CREATE TABLE rbi_tag (
id int NOT NULL AUTO_INCREMENT,
name varchar(255),
PRIMARY KEY (id)
);
CREATE TABLE rbi_referral_type (
id int NOT NULL AUTO_INCREMENT,
name varchar(255),
PRIMARY KEY (id)
);
INSERT INTO `rbi_referral_type`(`name`) VALUES ('Social Media')
INSERT INTO `rbi_referral_type`(`name`) VALUES ('Person')
INSERT INTO `rbi_referral_type`(`name`) VALUES ('Event')
INSERT INTO `rbi_referral_type`(`name`) VALUES ('Website')
INSERT INTO `rbi_referral_type`(`name`) VALUES ('Other')
CREATE TABLE rbi_person_tag (
person_id int NOT NULL,
tag_id int NOT NULL,
PRIMARY KEY (person_id, tag_id),
FOREIGN KEY (person_id) REFERENCES wp_zbs_contacts(ID),
FOREIGN KEY (tag_id) REFERENCES rbi_tag(id)
);
CREATE TABLE rbi_volunteer_event (
id int NOT NULL AUTO_INCREMENT,
event_id int NOT NULL,
person_id int NOT NULL,
start_time time(6),
end_time time(6),
PRIMARY KEY (id),
FOREIGN KEY (event_id) REFERENCES rbi_event(id),
FOREIGN KEY (person_id) REFERENCES wp_zbs_contacts(ID),
);
CREATE TABLE rbi_volunteer_event_tag (
volunteer_event_id int NOT NULL,
tag_id int NOT NULL,
PRIMARY KEY (volunteer_event_id, tag_id),
FOREIGN KEY (volunteer_event_id) REFERENCES rbi_volunteer_event(id),
FOREIGN KEY (tag_id) REFERENCES rbi_tag(id)
);
CREATE TABLE rbi_participant_event (
id int NOT NULL AUTO_INCREMENT,
event_id int NOT NULL,
person_id int NOT NULL,
referral_type_id int(11),
referral_notes varchar(255),
PRIMARY KEY (id),
FOREIGN KEY (event_id) REFERENCES rbi_event(id),
FOREIGN KEY (person_id) REFERENCES wp_zbs_contacts(ID),
FOREIGN KEY (referral_type_id) REFERENCES rbi_referral_type(id)
);
CREATE TABLE rbi_volunteer_availability (
id int NOT NULL AUTO_INCREMENT,
person_id int NOT NULL,
day varchar(255),
start_time time(6),
end_time time(6),
PRIMARY KEY (id),
FOREIGN KEY (person_id) REFERENCES wp_zbs_contacts(ID),
);