質問編集履歴

1

サンプルデータのSQLを追加しました。

2019/08/02 12:25

投稿

wasabin
wasabin

スコア13

test CHANGED
File without changes
test CHANGED
@@ -160,6 +160,100 @@
160
160
 
161
161
 
162
162
 
163
- ## 補足情報
163
+ # 補足情報
164
164
 
165
165
  MySQL 5.7
166
+
167
+
168
+
169
+ # サンプルデータ
170
+
171
+ ```
172
+
173
+ CREATE TABLE `categories` (
174
+
175
+ `id` int(11) NOT NULL AUTO_INCREMENT,
176
+
177
+ `name` varchar(50) DEFAULT NULL,
178
+
179
+ PRIMARY KEY (`id`)
180
+
181
+ ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
182
+
183
+
184
+
185
+ INSERT INTO `categories` VALUES (1,'そば'),(2,'うどん'),(3,'ラーメン'),(4,'カフェ'),(5,'ファストフード'),(6,'ピザ'),(7,'ワインバー'),(8,'居酒屋'),(9,'イタリアン');
186
+
187
+
188
+
189
+
190
+
191
+ CREATE TABLE `location_categories` (
192
+
193
+ `location_id` int(11) NOT NULL,
194
+
195
+ `category_id` int(11) NOT NULL,
196
+
197
+ UNIQUE KEY `location_id` (`location_id`,`category_id`)
198
+
199
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
200
+
201
+ INSERT INTO `location_categories` VALUES (1,4),(2,1),(2,2),(3,6),(3,7),(3,9),(4,4),(5,3),(6,5);
202
+
203
+
204
+
205
+
206
+
207
+ CREATE TABLE `location_tags` (
208
+
209
+ `location_id` int(11) NOT NULL,
210
+
211
+ `tag_id` int(11) NOT NULL,
212
+
213
+ UNIQUE KEY `location_id` (`location_id`,`tag_id`)
214
+
215
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
216
+
217
+
218
+
219
+ INSERT INTO `location_tags` VALUES (1,3),(1,4),(2,3),(2,4),(3,1),(3,4),(3,5),(4,1),(4,5),(6,1),(6,2);
220
+
221
+
222
+
223
+
224
+
225
+ CREATE TABLE `locations` (
226
+
227
+ `id` int(11) NOT NULL AUTO_INCREMENT,
228
+
229
+ `name` varchar(50) DEFAULT NULL,
230
+
231
+ PRIMARY KEY (`id`)
232
+
233
+ ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
234
+
235
+
236
+
237
+ INSERT INTO `locations` VALUES (2,'○×庵'),(3,'トラットリア FooBar'),(4,'Cafe Example'),(5,'Hoge家'),(6,'Burger Test');
238
+
239
+
240
+
241
+ CREATE TABLE `tags` (
242
+
243
+ `id` int(11) NOT NULL AUTO_INCREMENT,
244
+
245
+ `name` varchar(50) DEFAULT NULL,
246
+
247
+ PRIMARY KEY (`id`)
248
+
249
+ ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
250
+
251
+
252
+
253
+ INSERT INTO `tags` VALUES (1,'テイクアウト'),(2,'ドライブスルー'),(3,'出前'),(4,'トイレ'),(5,'予約'),(6,'貸し切り');
254
+
255
+
256
+
257
+
258
+
259
+ ```