euglena1215 / isucon7q-20190427

Apache License 2.0
0 stars 0 forks source link

DB #2

Closed spring1018 closed 5 years ago

spring1018 commented 5 years ago
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| isubata            |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)
euglena1215 commented 5 years ago
mysql> show tables;
+-------------------+
| Tables_in_isubata |
+-------------------+
| channel           |
| haveread          |
| image             |
| message           |
| user              |
+-------------------+
5 rows in set (0.00 sec)
euglena1215 commented 5 years ago

chennel

mysql> show create tables channel
    -> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tables channel' at line 1
mysql> show create table channel;
+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table   | Create Table                                                                                                                                                                                                                                             |
+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| channel | CREATE TABLE `channel` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` text NOT NULL,
  `description` mediumtext,
  `updated_at` datetime NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT * FROM channel;
+----+-------------------+-----------------------------------+---------------------+---------------------+
| id | name              | description                       | updated_at          | created_at          |
+----+-------------------+-----------------------------------+---------------------+---------------------+
|  1 | 1ちゃんねる  | ここは 1ちゃんねるです  | 2017-01-01 00:02:00 | 2017-01-01 00:02:00 |
|  2 | 2ちゃんねる  | ここは 2ちゃんねるです  | 2017-01-01 00:03:00 | 2017-01-01 00:03:00 |
|  3 | 3ちゃんねる  | ここは 3ちゃんねるです  | 2017-01-01 00:04:00 | 2017-01-01 00:04:00 |
|  4 | 4ちゃんねる  | ここは 4ちゃんねるです  | 2017-01-01 00:05:00 | 2017-01-01 00:05:00 |
|  5 | 5ちゃんねる  | ここは 5ちゃんねるです  | 2017-01-01 00:06:00 | 2017-01-01 00:06:00 |
|  6 | 6ちゃんねる  | ここは 6ちゃんねるです  | 2017-01-01 00:07:00 | 2017-01-01 00:07:00 |
|  7 | 7ちゃんねる  | ここは 7ちゃんねるです  | 2017-01-01 00:08:00 | 2017-01-01 00:08:00 |
|  8 | 8ちゃんねる  | ここは 8ちゃんねるです  | 2017-01-01 00:09:00 | 2017-01-01 00:09:00 |
|  9 | 9ちゃんねる  | ここは 9ちゃんねるです  | 2017-01-01 00:10:00 | 2017-01-01 00:10:00 |
| 10 | 10ちゃんねる | ここは 10ちゃんねるです | 2017-01-01 00:11:00 | 2017-01-01 00:11:00 |
+----+-------------------+-----------------------------------+---------------------+---------------------+
10 rows in set (0.00 sec)
euglena1215 commented 5 years ago

haveread

mysql> show create table haveread;
+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table    | Create Table                                                                                                                                                                                                                                                                              |
+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| haveread | CREATE TABLE `haveread` (
  `user_id` bigint(20) NOT NULL,
  `channel_id` bigint(20) NOT NULL,
  `message_id` bigint(20) DEFAULT NULL,
  `updated_at` datetime NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`user_id`,`channel_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT   * FROM   haveread  LIMIT 5;
Empty set (0.00 sec)
spring1018 commented 5 years ago

image

mysql> show create table image
    -> ;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                       |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| image | CREATE TABLE `image` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(191) DEFAULT NULL,
  `data` longblob,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1002 DEFAULT CHARSET=utf8mb4 |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
spring1018 commented 5 years ago

message

+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table   | Create Table                                                                                                                                                                                                                                                                           |
+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| message | CREATE TABLE `message` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `channel_id` bigint(20) DEFAULT NULL,
  `user_id` bigint(20) DEFAULT NULL,
  `content` text,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8mb4 |
+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT * FROM message LIMIT 5;                                                                                 +----+------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+
| id | channel_id | user_id | content                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | created_at          |
+----+------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+
|  1 |          4 |       1 | 死ぬのが万物の定業で、生きていてもあんまり役に立たないなら、早く死ぬだけが賢こいかも知れない。そんな浮気な男が何故牡蠣的生涯を送っているかと云うのは吾輩猫などには到底分らない。すると六人出て来た。                                                                                                                                                                                                                                                                         | 2017-03-01 00:00:00 |
|  2 |          8 |       2 | 私は先生と別れる時に、これから折々お宅へ伺っても宜ござんすかと聞いた。挨拶をするとへえと恐縮して頭を下げるから気の毒になる。しかしみんな奥さんに命令されて行ったのです。                                                                                                                                                                                                                                                                                                                   | 2017-03-01 00:00:17 |
|  3 |          7 |       3 | 三年間一生懸命にやれば何か出来る。その剰余を君に廻わすと云うのだから、君は誰にも気の毒がる必要はないはずです。半紙で包んで、封じ目を鄭寧に糊で貼り付けてあった。                                                                                                                                                                                                                                                                                                                               | 2017-03-01 00:00:34 |
|  4 |          6 |       4 | どうも驚ろいちまうわでも大変いい器量だって云うじゃありませんか並ですわ。ところが日は暮れる、路は分らず、腹は減る、仕方がないから峠の真中にある一軒屋を敲いて、これこれかようかようしかじかの次第だから、どうか留めてくれと云うと、御安い御用です、さあ御上がんなさいと裸蝋燭を僕の顔に差しつけた娘の顔を見て僕はぶるぶると悸えたがね。この病気を癒す方法は愚考によるとただ一つある。 | 2017-03-01 00:00:51 |
|  5 |          2 |       5 | 奥さんはそれでも丈夫そうになったといって賞めてくれるのです。私は不安を感ずると共に度胸を据えた。それがわからんと主張するならまず三日ばかり主人のうちへ宿りに来て見るがいい。                                                                                                                                                                                                                                                                                                             | 2017-03-01 00:01:08 |
+----+------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+
5 rows in set (0.00 sec)
spring1018 commented 5 years ago

user

mysql> show create table user;
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                                                                                                                                                                                          |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| user  | CREATE TABLE `user` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(191) DEFAULT NULL,
  `salt` varchar(20) DEFAULT NULL,
  `password` varchar(40) DEFAULT NULL,
  `display_name` text,
  `avatar_icon` text,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=utf8mb4 |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT * FROM user LIMIT 5;
+----+---------------------+----------------------+------------------------------------------+------------------+----------------------------------------------+---------------------+
| id | name                | salt                 | password                                 | display_name     | avatar_icon                                  | created_at          |
+----+---------------------+----------------------+------------------------------------------+------------------+----------------------------------------------+---------------------+
|  1 | ihara_yuuichi       | NxxyliZMmLpoXoAKVLtN | 648d90c0759fdc5bbe5dd75b0a402dd79e25f26a | 井原 勇一    | 1ce0c4ff504f19f267e877a9e244d60ac0bf1a41.png | 2017-02-01 00:00:00 |
|  2 | yanagida_yoshino    | vuAHywVmCrDttUCmfSwp | 1d5f3b4e01f5b7b155a8c8006ce19fc0a6f0005f | 柳田 佳乃    | 846f4f0bde2a2103c71936091e82bc1354f11b3a.png | 2017-02-03 12:56:00 |
|  3 | tabata_hitomi       | taearwsTMwevJUPJvxDv | 034b22fee67f764e2bb3378d5371f728296f3a9d | 田端 ひとみ | 8628ef0f034d734729e3a735362e6008b30bb72b.png | 2017-02-06 01:52:00 |
|  4 | yoshinaga_mitsuhiro | TWXmRSHYyCVGXIQqfgrO | d4d981a202d3a87beeed06d89136a6dc0460fcdf | 吉永 光洋    | d9efb5732e0ee53618bd10d2ddc5a6b33edc4751.png | 2017-02-08 14:48:00 |
|  5 | toji_tsutomu        | diQCYnpSMfAfakMwWHbH | 7ae539a9a749600b0d850e8f7ede418a2283d0e2 | ト字 勤       | 851e9e15e1d1fff39c2d182881926d107154c44a.png | 2017-02-11 03:44:00 |
+----+---------------------+----------------------+------------------------------------------+------------------+----------------------------------------------+---------------------+
5 rows in set (0.00 sec)
spring1018 commented 5 years ago

Index

channel

id

message

channel_id

image

user

haveread

(user_id, channel_id)