composite_primary_keys 8.1.0 → 8.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +642 -625
- data/README.rdoc +5 -2
- data/lib/composite_primary_keys.rb +115 -115
- data/lib/composite_primary_keys/associations/association.rb +23 -23
- data/lib/composite_primary_keys/associations/association_scope.rb +73 -73
- data/lib/composite_primary_keys/associations/collection_association.rb +14 -14
- data/lib/composite_primary_keys/associations/has_many_association.rb +69 -69
- data/lib/composite_primary_keys/associations/join_dependency.rb +87 -87
- data/lib/composite_primary_keys/associations/preloader/association.rb +90 -90
- data/lib/composite_primary_keys/associations/singular_association.rb +18 -18
- data/lib/composite_primary_keys/attribute_methods.rb +9 -9
- data/lib/composite_primary_keys/attribute_methods/dirty.rb +29 -29
- data/lib/composite_primary_keys/attribute_methods/read.rb +24 -24
- data/lib/composite_primary_keys/attribute_methods/write.rb +30 -30
- data/lib/composite_primary_keys/attribute_set/builder.rb +19 -19
- data/lib/composite_primary_keys/base.rb +129 -135
- data/lib/composite_primary_keys/composite_arrays.rb +43 -43
- data/lib/composite_primary_keys/connection_adapters/abstract/connection_specification_changes.rb +2 -3
- data/lib/composite_primary_keys/core.rb +60 -60
- data/lib/composite_primary_keys/persistence.rb +56 -56
- data/lib/composite_primary_keys/relation.rb +68 -68
- data/lib/composite_primary_keys/relation/calculations.rb +78 -78
- data/lib/composite_primary_keys/relation/finder_methods.rb +179 -179
- data/lib/composite_primary_keys/sanitization.rb +52 -52
- data/lib/composite_primary_keys/validations/uniqueness.rb +36 -36
- data/lib/composite_primary_keys/version.rb +8 -8
- data/tasks/databases/sqlserver.rake +27 -27
- data/test/abstract_unit.rb +114 -113
- data/test/connections/databases.example.yml +25 -25
- data/test/connections/native_sqlserver/connection.rb +11 -11
- data/test/fixtures/db_definitions/mysql.sql +218 -218
- data/test/fixtures/db_definitions/postgresql.sql +220 -220
- data/test/fixtures/db_definitions/sqlite.sql +206 -206
- data/test/fixtures/db_definitions/sqlserver.drop.sql +91 -91
- data/test/fixtures/db_definitions/sqlserver.sql +226 -226
- data/test/fixtures/employee.rb +11 -11
- data/test/fixtures/salary.rb +5 -5
- data/test/test_associations.rb +341 -340
- data/test/test_attributes.rb +60 -60
- data/test/test_create.rb +157 -157
- data/test/test_delete.rb +158 -158
- data/test/test_delete_all.rb +33 -28
- data/test/test_enum.rb +21 -21
- data/test/test_equal.rb +26 -26
- data/test/test_find.rb +119 -118
- data/test/test_habtm.rb +117 -113
- data/test/test_polymorphic.rb +27 -26
- data/test/test_tutorial_example.rb +25 -25
- metadata +44 -2
@@ -1,220 +1,220 @@
|
|
1
|
-
create table topics (
|
2
|
-
id serial not null,
|
3
|
-
name varchar(50) default null,
|
4
|
-
feed_size int default null,
|
5
|
-
primary key (id)
|
6
|
-
);
|
7
|
-
|
8
|
-
create table topic_sources (
|
9
|
-
topic_id int not null,
|
10
|
-
platform varchar(50) not null,
|
11
|
-
keywords varchar(50) default null,
|
12
|
-
primary key (topic_id,platform)
|
13
|
-
);
|
14
|
-
|
15
|
-
create table reference_types (
|
16
|
-
reference_type_id serial not null,
|
17
|
-
type_label varchar(50) default null,
|
18
|
-
abbreviation varchar(50) default null,
|
19
|
-
description varchar(50) default null,
|
20
|
-
primary key (reference_type_id)
|
21
|
-
);
|
22
|
-
|
23
|
-
create table reference_codes (
|
24
|
-
reference_type_id int,
|
25
|
-
reference_code int not null,
|
26
|
-
code_label varchar(50) default null,
|
27
|
-
abbreviation varchar(50) default null,
|
28
|
-
description varchar(50) default null,
|
29
|
-
primary key (reference_type_id, reference_code)
|
30
|
-
);
|
31
|
-
|
32
|
-
create table products (
|
33
|
-
id serial not null,
|
34
|
-
name varchar(50) default null,
|
35
|
-
primary key (id),
|
36
|
-
created_at timestamp without time zone NOT NULL,
|
37
|
-
updated_at timestamp without time zone NOT NULL
|
38
|
-
);
|
39
|
-
|
40
|
-
create table tariffs (
|
41
|
-
tariff_id int not null,
|
42
|
-
start_date date not null,
|
43
|
-
amount int default null,
|
44
|
-
primary key (tariff_id, start_date),
|
45
|
-
created_at timestamp without time zone NOT NULL,
|
46
|
-
updated_at timestamp without time zone NOT NULL
|
47
|
-
);
|
48
|
-
|
49
|
-
create table product_tariffs (
|
50
|
-
product_id int not null,
|
51
|
-
tariff_id int not null,
|
52
|
-
tariff_start_date date not null,
|
53
|
-
primary key (product_id, tariff_id, tariff_start_date)
|
54
|
-
);
|
55
|
-
|
56
|
-
create table suburbs (
|
57
|
-
city_id int not null,
|
58
|
-
suburb_id int not null,
|
59
|
-
name varchar(50) not null,
|
60
|
-
primary key (city_id, suburb_id)
|
61
|
-
);
|
62
|
-
|
63
|
-
create table streets (
|
64
|
-
id serial not null,
|
65
|
-
city_id int not null,
|
66
|
-
suburb_id int not null,
|
67
|
-
name varchar(50) not null,
|
68
|
-
primary key (id)
|
69
|
-
);
|
70
|
-
|
71
|
-
create table users (
|
72
|
-
id serial not null,
|
73
|
-
name varchar(50) not null,
|
74
|
-
primary key (id)
|
75
|
-
);
|
76
|
-
|
77
|
-
create table articles (
|
78
|
-
id serial not null,
|
79
|
-
name varchar(50) not null,
|
80
|
-
primary key (id)
|
81
|
-
);
|
82
|
-
|
83
|
-
create table readings (
|
84
|
-
id serial not null,
|
85
|
-
user_id int not null,
|
86
|
-
article_id int not null,
|
87
|
-
rating int not null,
|
88
|
-
primary key (id)
|
89
|
-
);
|
90
|
-
|
91
|
-
create table groups (
|
92
|
-
id serial not null,
|
93
|
-
name varchar(50) not null,
|
94
|
-
primary key (id)
|
95
|
-
);
|
96
|
-
|
97
|
-
create table memberships (
|
98
|
-
user_id int not null,
|
99
|
-
group_id int not null,
|
100
|
-
primary key (user_id, group_id)
|
101
|
-
);
|
102
|
-
|
103
|
-
create table membership_statuses (
|
104
|
-
id serial not null,
|
105
|
-
user_id int not null,
|
106
|
-
group_id int not null,
|
107
|
-
status varchar(50) not null,
|
108
|
-
primary key (id)
|
109
|
-
);
|
110
|
-
|
111
|
-
create table departments (
|
112
|
-
department_id int not null,
|
113
|
-
location_id int not null,
|
114
|
-
primary key (department_id, location_id)
|
115
|
-
);
|
116
|
-
|
117
|
-
create table employees (
|
118
|
-
id serial not null,
|
119
|
-
department_id int default null,
|
120
|
-
location_id int default null,
|
121
|
-
primary key (id)
|
122
|
-
);
|
123
|
-
|
124
|
-
create table salaries (
|
125
|
-
id serial not null,
|
126
|
-
employee_id int,
|
127
|
-
location_id int,
|
128
|
-
year int not null,
|
129
|
-
month int not null,
|
130
|
-
value int default null,
|
131
|
-
primary key (id)
|
132
|
-
);
|
133
|
-
|
134
|
-
create table comments (
|
135
|
-
id serial not null,
|
136
|
-
person_id int default null,
|
137
|
-
shown int default null,
|
138
|
-
person_type varchar(100) default null,
|
139
|
-
hack_id int default null,
|
140
|
-
primary key (id)
|
141
|
-
);
|
142
|
-
|
143
|
-
create table hacks (
|
144
|
-
id serial not null,
|
145
|
-
name varchar(50) not null,
|
146
|
-
primary key (id)
|
147
|
-
);
|
148
|
-
|
149
|
-
create table restaurants (
|
150
|
-
franchise_id int not null,
|
151
|
-
store_id int not null,
|
152
|
-
name varchar(100),
|
153
|
-
lock_version int default 0,
|
154
|
-
primary key (franchise_id, store_id)
|
155
|
-
);
|
156
|
-
|
157
|
-
create table restaurants_suburbs (
|
158
|
-
franchise_id int not null,
|
159
|
-
store_id int not null,
|
160
|
-
city_id int not null,
|
161
|
-
suburb_id int not null
|
162
|
-
);
|
163
|
-
|
164
|
-
create table dorms (
|
165
|
-
id serial not null,
|
166
|
-
primary key (id)
|
167
|
-
);
|
168
|
-
|
169
|
-
create table rooms (
|
170
|
-
dorm_id int not null,
|
171
|
-
room_id int not null,
|
172
|
-
primary key (dorm_id, room_id)
|
173
|
-
);
|
174
|
-
|
175
|
-
create table room_attributes (
|
176
|
-
id serial not null,
|
177
|
-
name varchar(50),
|
178
|
-
primary key (id)
|
179
|
-
);
|
180
|
-
|
181
|
-
create table room_attribute_assignments (
|
182
|
-
dorm_id int not null,
|
183
|
-
room_id int not null,
|
184
|
-
room_attribute_id int not null
|
185
|
-
);
|
186
|
-
|
187
|
-
create table students (
|
188
|
-
id serial not null,
|
189
|
-
primary key (id)
|
190
|
-
);
|
191
|
-
|
192
|
-
create table room_assignments (
|
193
|
-
student_id int not null,
|
194
|
-
dorm_id int not null,
|
195
|
-
room_id int not null
|
196
|
-
);
|
197
|
-
|
198
|
-
create table seats (
|
199
|
-
flight_number int not null,
|
200
|
-
seat int not null,
|
201
|
-
customer int,
|
202
|
-
primary key (flight_number, seat)
|
203
|
-
);
|
204
|
-
|
205
|
-
create table capitols (
|
206
|
-
country text not null,
|
207
|
-
city text not null,
|
208
|
-
primary key (country, city)
|
209
|
-
);
|
210
|
-
|
211
|
-
create table products_restaurants (
|
212
|
-
product_id int not null,
|
213
|
-
franchise_id int not null,
|
214
|
-
store_id int not null
|
215
|
-
);
|
216
|
-
|
217
|
-
create table employees_groups (
|
218
|
-
employee_id int not null,
|
219
|
-
group_id int not null
|
220
|
-
);
|
1
|
+
create table topics (
|
2
|
+
id serial not null,
|
3
|
+
name varchar(50) default null,
|
4
|
+
feed_size int default null,
|
5
|
+
primary key (id)
|
6
|
+
);
|
7
|
+
|
8
|
+
create table topic_sources (
|
9
|
+
topic_id int not null,
|
10
|
+
platform varchar(50) not null,
|
11
|
+
keywords varchar(50) default null,
|
12
|
+
primary key (topic_id,platform)
|
13
|
+
);
|
14
|
+
|
15
|
+
create table reference_types (
|
16
|
+
reference_type_id serial not null,
|
17
|
+
type_label varchar(50) default null,
|
18
|
+
abbreviation varchar(50) default null,
|
19
|
+
description varchar(50) default null,
|
20
|
+
primary key (reference_type_id)
|
21
|
+
);
|
22
|
+
|
23
|
+
create table reference_codes (
|
24
|
+
reference_type_id int,
|
25
|
+
reference_code int not null,
|
26
|
+
code_label varchar(50) default null,
|
27
|
+
abbreviation varchar(50) default null,
|
28
|
+
description varchar(50) default null,
|
29
|
+
primary key (reference_type_id, reference_code)
|
30
|
+
);
|
31
|
+
|
32
|
+
create table products (
|
33
|
+
id serial not null,
|
34
|
+
name varchar(50) default null,
|
35
|
+
primary key (id),
|
36
|
+
created_at timestamp without time zone NOT NULL,
|
37
|
+
updated_at timestamp without time zone NOT NULL
|
38
|
+
);
|
39
|
+
|
40
|
+
create table tariffs (
|
41
|
+
tariff_id int not null,
|
42
|
+
start_date date not null,
|
43
|
+
amount int default null,
|
44
|
+
primary key (tariff_id, start_date),
|
45
|
+
created_at timestamp without time zone NOT NULL,
|
46
|
+
updated_at timestamp without time zone NOT NULL
|
47
|
+
);
|
48
|
+
|
49
|
+
create table product_tariffs (
|
50
|
+
product_id int not null,
|
51
|
+
tariff_id int not null,
|
52
|
+
tariff_start_date date not null,
|
53
|
+
primary key (product_id, tariff_id, tariff_start_date)
|
54
|
+
);
|
55
|
+
|
56
|
+
create table suburbs (
|
57
|
+
city_id int not null,
|
58
|
+
suburb_id int not null,
|
59
|
+
name varchar(50) not null,
|
60
|
+
primary key (city_id, suburb_id)
|
61
|
+
);
|
62
|
+
|
63
|
+
create table streets (
|
64
|
+
id serial not null,
|
65
|
+
city_id int not null,
|
66
|
+
suburb_id int not null,
|
67
|
+
name varchar(50) not null,
|
68
|
+
primary key (id)
|
69
|
+
);
|
70
|
+
|
71
|
+
create table users (
|
72
|
+
id serial not null,
|
73
|
+
name varchar(50) not null,
|
74
|
+
primary key (id)
|
75
|
+
);
|
76
|
+
|
77
|
+
create table articles (
|
78
|
+
id serial not null,
|
79
|
+
name varchar(50) not null,
|
80
|
+
primary key (id)
|
81
|
+
);
|
82
|
+
|
83
|
+
create table readings (
|
84
|
+
id serial not null,
|
85
|
+
user_id int not null,
|
86
|
+
article_id int not null,
|
87
|
+
rating int not null,
|
88
|
+
primary key (id)
|
89
|
+
);
|
90
|
+
|
91
|
+
create table groups (
|
92
|
+
id serial not null,
|
93
|
+
name varchar(50) not null,
|
94
|
+
primary key (id)
|
95
|
+
);
|
96
|
+
|
97
|
+
create table memberships (
|
98
|
+
user_id int not null,
|
99
|
+
group_id int not null,
|
100
|
+
primary key (user_id, group_id)
|
101
|
+
);
|
102
|
+
|
103
|
+
create table membership_statuses (
|
104
|
+
id serial not null,
|
105
|
+
user_id int not null,
|
106
|
+
group_id int not null,
|
107
|
+
status varchar(50) not null,
|
108
|
+
primary key (id)
|
109
|
+
);
|
110
|
+
|
111
|
+
create table departments (
|
112
|
+
department_id int not null,
|
113
|
+
location_id int not null,
|
114
|
+
primary key (department_id, location_id)
|
115
|
+
);
|
116
|
+
|
117
|
+
create table employees (
|
118
|
+
id serial not null,
|
119
|
+
department_id int default null,
|
120
|
+
location_id int default null,
|
121
|
+
primary key (id)
|
122
|
+
);
|
123
|
+
|
124
|
+
create table salaries (
|
125
|
+
id serial not null,
|
126
|
+
employee_id int,
|
127
|
+
location_id int,
|
128
|
+
year int not null,
|
129
|
+
month int not null,
|
130
|
+
value int default null,
|
131
|
+
primary key (id)
|
132
|
+
);
|
133
|
+
|
134
|
+
create table comments (
|
135
|
+
id serial not null,
|
136
|
+
person_id int default null,
|
137
|
+
shown int default null,
|
138
|
+
person_type varchar(100) default null,
|
139
|
+
hack_id int default null,
|
140
|
+
primary key (id)
|
141
|
+
);
|
142
|
+
|
143
|
+
create table hacks (
|
144
|
+
id serial not null,
|
145
|
+
name varchar(50) not null,
|
146
|
+
primary key (id)
|
147
|
+
);
|
148
|
+
|
149
|
+
create table restaurants (
|
150
|
+
franchise_id int not null,
|
151
|
+
store_id int not null,
|
152
|
+
name varchar(100),
|
153
|
+
lock_version int default 0,
|
154
|
+
primary key (franchise_id, store_id)
|
155
|
+
);
|
156
|
+
|
157
|
+
create table restaurants_suburbs (
|
158
|
+
franchise_id int not null,
|
159
|
+
store_id int not null,
|
160
|
+
city_id int not null,
|
161
|
+
suburb_id int not null
|
162
|
+
);
|
163
|
+
|
164
|
+
create table dorms (
|
165
|
+
id serial not null,
|
166
|
+
primary key (id)
|
167
|
+
);
|
168
|
+
|
169
|
+
create table rooms (
|
170
|
+
dorm_id int not null,
|
171
|
+
room_id int not null,
|
172
|
+
primary key (dorm_id, room_id)
|
173
|
+
);
|
174
|
+
|
175
|
+
create table room_attributes (
|
176
|
+
id serial not null,
|
177
|
+
name varchar(50),
|
178
|
+
primary key (id)
|
179
|
+
);
|
180
|
+
|
181
|
+
create table room_attribute_assignments (
|
182
|
+
dorm_id int not null,
|
183
|
+
room_id int not null,
|
184
|
+
room_attribute_id int not null
|
185
|
+
);
|
186
|
+
|
187
|
+
create table students (
|
188
|
+
id serial not null,
|
189
|
+
primary key (id)
|
190
|
+
);
|
191
|
+
|
192
|
+
create table room_assignments (
|
193
|
+
student_id int not null,
|
194
|
+
dorm_id int not null,
|
195
|
+
room_id int not null
|
196
|
+
);
|
197
|
+
|
198
|
+
create table seats (
|
199
|
+
flight_number int not null,
|
200
|
+
seat int not null,
|
201
|
+
customer int,
|
202
|
+
primary key (flight_number, seat)
|
203
|
+
);
|
204
|
+
|
205
|
+
create table capitols (
|
206
|
+
country text not null,
|
207
|
+
city text not null,
|
208
|
+
primary key (country, city)
|
209
|
+
);
|
210
|
+
|
211
|
+
create table products_restaurants (
|
212
|
+
product_id int not null,
|
213
|
+
franchise_id int not null,
|
214
|
+
store_id int not null
|
215
|
+
);
|
216
|
+
|
217
|
+
create table employees_groups (
|
218
|
+
employee_id int not null,
|
219
|
+
group_id int not null
|
220
|
+
);
|
@@ -1,206 +1,206 @@
|
|
1
|
-
create table topics (
|
2
|
-
id int not null,
|
3
|
-
name varchar(50) default null,
|
4
|
-
feed_size int default null,
|
5
|
-
primary key (id)
|
6
|
-
);
|
7
|
-
|
8
|
-
create table topic_sources (
|
9
|
-
topic_id int not null,
|
10
|
-
platform varchar(50) not null,
|
11
|
-
keywords varchar(50) default null,
|
12
|
-
primary key (topic_id,platform)
|
13
|
-
);
|
14
|
-
|
15
|
-
create table reference_types (
|
16
|
-
reference_type_id integer primary key,
|
17
|
-
type_label varchar(50) default null,
|
18
|
-
abbreviation varchar(50) default null,
|
19
|
-
description varchar(50) default null
|
20
|
-
);
|
21
|
-
|
22
|
-
create table reference_codes (
|
23
|
-
reference_type_id int(11),
|
24
|
-
reference_code int(11) not null,
|
25
|
-
code_label varchar(50) default null,
|
26
|
-
abbreviation varchar(50) default null,
|
27
|
-
description varchar(50) default null,
|
28
|
-
primary key (reference_type_id, reference_code)
|
29
|
-
);
|
30
|
-
|
31
|
-
create table products (
|
32
|
-
id int(11) not null primary key,
|
33
|
-
name varchar(50) default null,
|
34
|
-
created_at TIMESTAMP,
|
35
|
-
updated_at TIMESTAMP
|
36
|
-
);
|
37
|
-
|
38
|
-
create table tariffs (
|
39
|
-
tariff_id int(11) not null,
|
40
|
-
start_date date not null,
|
41
|
-
amount integer(11) default null,
|
42
|
-
created_at TIMESTAMP,
|
43
|
-
updated_at TIMESTAMP,
|
44
|
-
primary key (tariff_id, start_date)
|
45
|
-
);
|
46
|
-
|
47
|
-
create table product_tariffs (
|
48
|
-
product_id int(11) not null,
|
49
|
-
tariff_id int(11) not null,
|
50
|
-
tariff_start_date date not null,
|
51
|
-
primary key (product_id, tariff_id, tariff_start_date)
|
52
|
-
);
|
53
|
-
|
54
|
-
create table suburbs (
|
55
|
-
city_id int(11) not null,
|
56
|
-
suburb_id int(11) not null,
|
57
|
-
name varchar(50) not null,
|
58
|
-
primary key (city_id, suburb_id)
|
59
|
-
);
|
60
|
-
|
61
|
-
create table streets (
|
62
|
-
id integer not null primary key autoincrement,
|
63
|
-
city_id int(11) not null,
|
64
|
-
suburb_id int(11) not null,
|
65
|
-
name varchar(50) not null
|
66
|
-
);
|
67
|
-
|
68
|
-
create table users (
|
69
|
-
id integer not null primary key autoincrement,
|
70
|
-
name varchar(50) not null
|
71
|
-
);
|
72
|
-
|
73
|
-
create table articles (
|
74
|
-
id integer not null primary key autoincrement,
|
75
|
-
name varchar(50) not null
|
76
|
-
);
|
77
|
-
|
78
|
-
create table readings (
|
79
|
-
id integer not null primary key autoincrement,
|
80
|
-
user_id int(11) not null,
|
81
|
-
article_id int(11) not null,
|
82
|
-
rating int(11) not null
|
83
|
-
);
|
84
|
-
|
85
|
-
create table groups (
|
86
|
-
id integer not null primary key autoincrement,
|
87
|
-
name varchar(50) not null
|
88
|
-
);
|
89
|
-
|
90
|
-
create table memberships (
|
91
|
-
user_id int not null,
|
92
|
-
group_id int not null,
|
93
|
-
primary key (user_id, group_id)
|
94
|
-
);
|
95
|
-
|
96
|
-
create table membership_statuses (
|
97
|
-
id integer not null primary key autoincrement,
|
98
|
-
user_id int not null,
|
99
|
-
group_id int not null,
|
100
|
-
status varchar(50) not null
|
101
|
-
);
|
102
|
-
|
103
|
-
create table departments (
|
104
|
-
department_id integer not null,
|
105
|
-
location_id integer not null,
|
106
|
-
primary key (department_id, location_id)
|
107
|
-
);
|
108
|
-
|
109
|
-
create table employees (
|
110
|
-
id integer not null primary key autoincrement,
|
111
|
-
department_id integer null,
|
112
|
-
location_id integer null
|
113
|
-
);
|
114
|
-
|
115
|
-
create table salaries (
|
116
|
-
id integer not null primary key autoincrement,
|
117
|
-
employee_id integer,
|
118
|
-
location_id integer,
|
119
|
-
year int not null,
|
120
|
-
month int not null,
|
121
|
-
value int default null
|
122
|
-
);
|
123
|
-
|
124
|
-
create table comments (
|
125
|
-
id integer not null primary key autoincrement,
|
126
|
-
person_id int null,
|
127
|
-
shown int null,
|
128
|
-
person_type varchar(100) null,
|
129
|
-
hack_id int null
|
130
|
-
);
|
131
|
-
|
132
|
-
create table hacks (
|
133
|
-
id integer not null primary key autoincrement,
|
134
|
-
name varchar(50) not null
|
135
|
-
);
|
136
|
-
|
137
|
-
create table restaurants (
|
138
|
-
franchise_id integer not null,
|
139
|
-
store_id integer not null,
|
140
|
-
name varchar(100),
|
141
|
-
lock_version integer default 0,
|
142
|
-
primary key (franchise_id, store_id)
|
143
|
-
);
|
144
|
-
|
145
|
-
create table restaurants_suburbs (
|
146
|
-
franchise_id integer not null,
|
147
|
-
store_id integer not null,
|
148
|
-
city_id integer not null,
|
149
|
-
suburb_id integer not null
|
150
|
-
);
|
151
|
-
|
152
|
-
create table dorms (
|
153
|
-
id integer not null primary key autoincrement
|
154
|
-
);
|
155
|
-
|
156
|
-
create table rooms (
|
157
|
-
dorm_id integer not null,
|
158
|
-
room_id integer not null,
|
159
|
-
primary key (dorm_id, room_id)
|
160
|
-
);
|
161
|
-
|
162
|
-
create table room_attributes (
|
163
|
-
id integer not null primary key autoincrement,
|
164
|
-
name varchar(50)
|
165
|
-
);
|
166
|
-
|
167
|
-
create table room_attribute_assignments (
|
168
|
-
dorm_id integer not null,
|
169
|
-
room_id integer not null,
|
170
|
-
room_attribute_id integer not null
|
171
|
-
);
|
172
|
-
|
173
|
-
create table students (
|
174
|
-
id integer not null primary key autoincrement
|
175
|
-
);
|
176
|
-
|
177
|
-
create table room_assignments (
|
178
|
-
student_id integer not null,
|
179
|
-
dorm_id integer not null,
|
180
|
-
room_id integer not null
|
181
|
-
);
|
182
|
-
|
183
|
-
create table seats (
|
184
|
-
flight_number integer not_null,
|
185
|
-
seat integer not_null,
|
186
|
-
customer integer,
|
187
|
-
primary key (flight_number, seat)
|
188
|
-
);
|
189
|
-
|
190
|
-
create table capitols (
|
191
|
-
country text not null,
|
192
|
-
city text not null,
|
193
|
-
primary key (country, city)
|
194
|
-
);
|
195
|
-
|
196
|
-
create table products_restaurants (
|
197
|
-
product_id integer not null,
|
198
|
-
franchise_id integer not null,
|
199
|
-
store_id integer not null
|
200
|
-
);
|
201
|
-
|
202
|
-
create table employees_groups (
|
203
|
-
employee_id integer not null,
|
204
|
-
group_id integer not null
|
205
|
-
);
|
206
|
-
|
1
|
+
create table topics (
|
2
|
+
id int not null,
|
3
|
+
name varchar(50) default null,
|
4
|
+
feed_size int default null,
|
5
|
+
primary key (id)
|
6
|
+
);
|
7
|
+
|
8
|
+
create table topic_sources (
|
9
|
+
topic_id int not null,
|
10
|
+
platform varchar(50) not null,
|
11
|
+
keywords varchar(50) default null,
|
12
|
+
primary key (topic_id,platform)
|
13
|
+
);
|
14
|
+
|
15
|
+
create table reference_types (
|
16
|
+
reference_type_id integer primary key,
|
17
|
+
type_label varchar(50) default null,
|
18
|
+
abbreviation varchar(50) default null,
|
19
|
+
description varchar(50) default null
|
20
|
+
);
|
21
|
+
|
22
|
+
create table reference_codes (
|
23
|
+
reference_type_id int(11),
|
24
|
+
reference_code int(11) not null,
|
25
|
+
code_label varchar(50) default null,
|
26
|
+
abbreviation varchar(50) default null,
|
27
|
+
description varchar(50) default null,
|
28
|
+
primary key (reference_type_id, reference_code)
|
29
|
+
);
|
30
|
+
|
31
|
+
create table products (
|
32
|
+
id int(11) not null primary key,
|
33
|
+
name varchar(50) default null,
|
34
|
+
created_at TIMESTAMP,
|
35
|
+
updated_at TIMESTAMP
|
36
|
+
);
|
37
|
+
|
38
|
+
create table tariffs (
|
39
|
+
tariff_id int(11) not null,
|
40
|
+
start_date date not null,
|
41
|
+
amount integer(11) default null,
|
42
|
+
created_at TIMESTAMP,
|
43
|
+
updated_at TIMESTAMP,
|
44
|
+
primary key (tariff_id, start_date)
|
45
|
+
);
|
46
|
+
|
47
|
+
create table product_tariffs (
|
48
|
+
product_id int(11) not null,
|
49
|
+
tariff_id int(11) not null,
|
50
|
+
tariff_start_date date not null,
|
51
|
+
primary key (product_id, tariff_id, tariff_start_date)
|
52
|
+
);
|
53
|
+
|
54
|
+
create table suburbs (
|
55
|
+
city_id int(11) not null,
|
56
|
+
suburb_id int(11) not null,
|
57
|
+
name varchar(50) not null,
|
58
|
+
primary key (city_id, suburb_id)
|
59
|
+
);
|
60
|
+
|
61
|
+
create table streets (
|
62
|
+
id integer not null primary key autoincrement,
|
63
|
+
city_id int(11) not null,
|
64
|
+
suburb_id int(11) not null,
|
65
|
+
name varchar(50) not null
|
66
|
+
);
|
67
|
+
|
68
|
+
create table users (
|
69
|
+
id integer not null primary key autoincrement,
|
70
|
+
name varchar(50) not null
|
71
|
+
);
|
72
|
+
|
73
|
+
create table articles (
|
74
|
+
id integer not null primary key autoincrement,
|
75
|
+
name varchar(50) not null
|
76
|
+
);
|
77
|
+
|
78
|
+
create table readings (
|
79
|
+
id integer not null primary key autoincrement,
|
80
|
+
user_id int(11) not null,
|
81
|
+
article_id int(11) not null,
|
82
|
+
rating int(11) not null
|
83
|
+
);
|
84
|
+
|
85
|
+
create table groups (
|
86
|
+
id integer not null primary key autoincrement,
|
87
|
+
name varchar(50) not null
|
88
|
+
);
|
89
|
+
|
90
|
+
create table memberships (
|
91
|
+
user_id int not null,
|
92
|
+
group_id int not null,
|
93
|
+
primary key (user_id, group_id)
|
94
|
+
);
|
95
|
+
|
96
|
+
create table membership_statuses (
|
97
|
+
id integer not null primary key autoincrement,
|
98
|
+
user_id int not null,
|
99
|
+
group_id int not null,
|
100
|
+
status varchar(50) not null
|
101
|
+
);
|
102
|
+
|
103
|
+
create table departments (
|
104
|
+
department_id integer not null,
|
105
|
+
location_id integer not null,
|
106
|
+
primary key (department_id, location_id)
|
107
|
+
);
|
108
|
+
|
109
|
+
create table employees (
|
110
|
+
id integer not null primary key autoincrement,
|
111
|
+
department_id integer null,
|
112
|
+
location_id integer null
|
113
|
+
);
|
114
|
+
|
115
|
+
create table salaries (
|
116
|
+
id integer not null primary key autoincrement,
|
117
|
+
employee_id integer,
|
118
|
+
location_id integer,
|
119
|
+
year int not null,
|
120
|
+
month int not null,
|
121
|
+
value int default null
|
122
|
+
);
|
123
|
+
|
124
|
+
create table comments (
|
125
|
+
id integer not null primary key autoincrement,
|
126
|
+
person_id int null,
|
127
|
+
shown int null,
|
128
|
+
person_type varchar(100) null,
|
129
|
+
hack_id int null
|
130
|
+
);
|
131
|
+
|
132
|
+
create table hacks (
|
133
|
+
id integer not null primary key autoincrement,
|
134
|
+
name varchar(50) not null
|
135
|
+
);
|
136
|
+
|
137
|
+
create table restaurants (
|
138
|
+
franchise_id integer not null,
|
139
|
+
store_id integer not null,
|
140
|
+
name varchar(100),
|
141
|
+
lock_version integer default 0,
|
142
|
+
primary key (franchise_id, store_id)
|
143
|
+
);
|
144
|
+
|
145
|
+
create table restaurants_suburbs (
|
146
|
+
franchise_id integer not null,
|
147
|
+
store_id integer not null,
|
148
|
+
city_id integer not null,
|
149
|
+
suburb_id integer not null
|
150
|
+
);
|
151
|
+
|
152
|
+
create table dorms (
|
153
|
+
id integer not null primary key autoincrement
|
154
|
+
);
|
155
|
+
|
156
|
+
create table rooms (
|
157
|
+
dorm_id integer not null,
|
158
|
+
room_id integer not null,
|
159
|
+
primary key (dorm_id, room_id)
|
160
|
+
);
|
161
|
+
|
162
|
+
create table room_attributes (
|
163
|
+
id integer not null primary key autoincrement,
|
164
|
+
name varchar(50)
|
165
|
+
);
|
166
|
+
|
167
|
+
create table room_attribute_assignments (
|
168
|
+
dorm_id integer not null,
|
169
|
+
room_id integer not null,
|
170
|
+
room_attribute_id integer not null
|
171
|
+
);
|
172
|
+
|
173
|
+
create table students (
|
174
|
+
id integer not null primary key autoincrement
|
175
|
+
);
|
176
|
+
|
177
|
+
create table room_assignments (
|
178
|
+
student_id integer not null,
|
179
|
+
dorm_id integer not null,
|
180
|
+
room_id integer not null
|
181
|
+
);
|
182
|
+
|
183
|
+
create table seats (
|
184
|
+
flight_number integer not_null,
|
185
|
+
seat integer not_null,
|
186
|
+
customer integer,
|
187
|
+
primary key (flight_number, seat)
|
188
|
+
);
|
189
|
+
|
190
|
+
create table capitols (
|
191
|
+
country text not null,
|
192
|
+
city text not null,
|
193
|
+
primary key (country, city)
|
194
|
+
);
|
195
|
+
|
196
|
+
create table products_restaurants (
|
197
|
+
product_id integer not null,
|
198
|
+
franchise_id integer not null,
|
199
|
+
store_id integer not null
|
200
|
+
);
|
201
|
+
|
202
|
+
create table employees_groups (
|
203
|
+
employee_id integer not null,
|
204
|
+
group_id integer not null
|
205
|
+
);
|
206
|
+
|