-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathddl.sql
More file actions
221 lines (208 loc) · 9.68 KB
/
ddl.sql
File metadata and controls
221 lines (208 loc) · 9.68 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
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for addr
-- ----------------------------
DROP TABLE IF EXISTS `addr`;
CREATE TABLE `addr` (
`id` int(16) unsigned NOT NULL AUTO_INCREMENT,
`fkid` int(16) NOT NULL,
`addridx` int(12) NOT NULL,
`pkaddr` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- ----------------------------
-- Table structure for inscr
-- ----------------------------
DROP TABLE IF EXISTS `inscr`;
CREATE TABLE `inscr` (
`id` int(16) unsigned NOT NULL AUTO_INCREMENT,
`ord_id` int(16) NOT NULL,
`inscr_id` varchar(255) NOT NULL,
`gen_trx` varchar(255) DEFAULT NULL,
`output_no` int(4) DEFAULT NULL,
`adj_output_no` int(4) DEFAULT NULL,
`chain` varchar(255) NOT NULL DEFAULT 'mainnet',
`status` varchar(24) NOT NULL DEFAULT 'NEW',
`num_tags` int(4) NOT NULL DEFAULT 0,
`trxid` int(11) DEFAULT NULL,
`parstatus` varchar(24) NOT NULL DEFAULT 'NEW',
`parmessage` varchar(255) DEFAULT NULL,
`shadowing` int(16) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `inscr_uk` (`ord_id`,`chain`) USING BTREE,
KEY `num_tags_idx` (`num_tags`) USING BTREE,
KEY `ord_id_idx` (`ord_id`) USING BTREE,
KEY `inscr_id_idx` (`inscr_id`) USING BTREE,
KEY `status_idx` (`status`),
KEY `parstatus_idx` (`parstatus`),
KEY `driver_idx` (`chain`,`status`,`parstatus`) USING BTREE,
KEY `trxid_idx` (`trxid`),
KEY `gentrx_idx` (`gen_trx`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- ----------------------------
-- Table structure for inscr28
-- ----------------------------
DROP TABLE IF EXISTS `inscr28`;
CREATE TABLE `inscr28` (
`id` int(16) unsigned NOT NULL AUTO_INCREMENT,
`ord_id` int(16) NOT NULL,
`inscr_id` varchar(255) NOT NULL,
`inscr_loc` varchar(255) NOT NULL,
`gen_trx` varchar(255) DEFAULT NULL,
`output_no` int(4) DEFAULT NULL,
`adj_output_no` int(4) DEFAULT NULL,
`chain` varchar(255) NOT NULL DEFAULT 'mainnet',
`status` varchar(24) NOT NULL DEFAULT 'NEW',
`num_tags` int(4) NOT NULL DEFAULT 0,
`trxid` int(11) DEFAULT NULL,
`parstatus` varchar(24) NOT NULL DEFAULT 'NEW',
`parmessage` varchar(255) DEFAULT NULL,
`shadowing` int(16) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `inscr28_uk` (`ord_id`,`chain`) USING BTREE,
KEY `num_tags28_idx` (`num_tags`) USING BTREE,
KEY `ord_id28_idx` (`ord_id`) USING BTREE,
KEY `inscr28_id_idx` (`inscr_id`) USING BTREE,
KEY `status28_idx` (`status`),
KEY `parstatus28_idx` (`parstatus`),
KEY `driver28_idx` (`chain`,`status`,`parstatus`) USING BTREE,
KEY `trxid_idx` (`trxid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- ----------------------------
-- Table structure for ord_tags
-- ----------------------------
DROP TABLE IF EXISTS `ord_tags`;
CREATE TABLE `ord_tags` (
`id` int(16) unsigned NOT NULL AUTO_INCREMENT,
`inscr_tb_id` int(16) unsigned NOT NULL,
`ord_id` int(16) NOT NULL,
`tag_no` varchar(2) NOT NULL,
`tag_value` varchar(2000) DEFAULT NULL,
`tag_guess` varchar(2000) DEFAULT NULL,
`note` varchar(1000) DEFAULT NULL,
`chain` varchar(255) NOT NULL,
`notation_id` int(11) DEFAULT NULL,
`format_notation_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
KEY `tag_no_idx` (`tag_no`) USING HASH,
KEY `ord_id_idx` (`ord_id`) USING BTREE,
KEY `tag_to_inscr_fk` (`inscr_tb_id`),
CONSTRAINT `tag_to_inscr_fk` FOREIGN KEY (`inscr_tb_id`) REFERENCES `inscr` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for shadows
-- ----------------------------
DROP TABLE IF EXISTS `shadows`;
CREATE TABLE `shadows` (
`id` int(16) unsigned NOT NULL DEFAULT 0,
`ord_id` int(16) NOT NULL,
`real_ord_id` int(16) DEFAULT NULL,
`inscr_id` varchar(255) NOT NULL,
`gen_trx` varchar(255) DEFAULT NULL,
`output_no` int(4) DEFAULT NULL,
`adj_output_no` int(4) DEFAULT NULL,
`chain` varchar(255) NOT NULL DEFAULT 'mainnet',
`status` varchar(24) NOT NULL DEFAULT 'NEW',
`num_tags` int(4) NOT NULL DEFAULT 0,
`trxid` int(11) DEFAULT NULL,
`parstatus` varchar(24) NOT NULL DEFAULT 'NEW',
`parmessage` varchar(255) DEFAULT NULL,
`shadowing` int(16) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `shadow_light_idx` (`gen_trx`,`adj_output_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- ----------------------------
-- Table structure for tx
-- ----------------------------
DROP TABLE IF EXISTS `tx`;
CREATE TABLE `tx` (
`id` int(16) unsigned NOT NULL AUTO_INCREMENT,
`txid` char(64) NOT NULL,
`hash` char(64) NOT NULL,
`version` int(1) NOT NULL,
`txsize` int(16) NOT NULL,
`txvsize` int(16) NOT NULL,
`weight` int(16) NOT NULL,
`locktime` int(16) NOT NULL,
`vincount` int(16) unsigned NOT NULL DEFAULT 0,
`voutcount` int(16) unsigned NOT NULL DEFAULT 0,
`blockhash` char(64) NOT NULL,
`unixtime` int(12) NOT NULL,
`txtimedate` datetime NOT NULL,
`chainnet` varchar(24) NOT NULL DEFAULT 'mainnet',
PRIMARY KEY (`id`),
UNIQUE KEY `txid_uk` (`txid`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- ----------------------------
-- Table structure for vin
-- ----------------------------
DROP TABLE IF EXISTS `vin`;
CREATE TABLE `vin` (
`id` int(16) unsigned NOT NULL AUTO_INCREMENT,
`belongsto_fkid` int(16) NOT NULL,
`idxvin` int(16) NOT NULL,
`intxid` char(64) NOT NULL,
`invoutn` int(16) NOT NULL,
`vinseq` int(16) unsigned NOT NULL,
`witsize` int(16) NOT NULL DEFAULT 0,
`content_status` varchar(16) DEFAULT NULL,
`scriptsigasm` varchar(255) DEFAULT NULL,
`scriptsighex` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `vin_uk` (`intxid`,`invoutn`) USING BTREE,
KEY `vin_to_tx_fk` (`belongsto_fkid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- ----------------------------
-- Table structure for vout
-- ----------------------------
DROP TABLE IF EXISTS `vout`;
CREATE TABLE `vout` (
`id` int(16) unsigned NOT NULL AUTO_INCREMENT,
`belongsto_fkid` int(16) NOT NULL,
`valu` decimal(17,9) unsigned NOT NULL DEFAULT 0.000000000,
`n` int(16) unsigned NOT NULL,
`pkasm` varchar(2000) DEFAULT NULL,
`pkdesc` varchar(255) DEFAULT NULL,
`pkhex` varchar(255) DEFAULT NULL,
`reqsigs` int(16) DEFAULT 1,
`pktype` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `vout_uk` (`n`,`belongsto_fkid`) USING BTREE,
KEY `vout_to_tx_fk` (`belongsto_fkid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- ----------------------------
-- Table structure for wit
-- ----------------------------
DROP TABLE IF EXISTS `wit`;
CREATE TABLE `wit` (
`id` int(16) unsigned NOT NULL AUTO_INCREMENT,
`fkid_vin_tab` int(16) unsigned NOT NULL,
`belongsto_fkid_txid` int(16) unsigned NOT NULL,
`idxvin` int(16) NOT NULL,
`idxwit` int(16) NOT NULL,
`hashwit` varchar(64) DEFAULT NULL,
`withex` mediumtext NOT NULL,
`witbin` blob DEFAULT NULL,
`content_format` varchar(1000) DEFAULT NULL,
`unwrapped_content` mediumtext DEFAULT NULL,
`unhexlified_cont` mediumtext DEFAULT NULL,
`rstatus` varchar(255) NOT NULL DEFAULT 'NEW',
`recordclass` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `wit_uk` (`idxwit`,`fkid_vin_tab`) USING BTREE,
UNIQUE KEY `wit_content_uk` (`hashwit`,`fkid_vin_tab`,`idxwit`) USING BTREE,
KEY `txwit_to_tx_fk` (`fkid_vin_tab`),
KEY `content_idx` (`unwrapped_content`(768))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- ----------------------------
-- View structure for non_01_tags
-- ----------------------------
DROP VIEW IF EXISTS `non_01_tags`;
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `non_01_tags` AS select `si`.`id` AS `id`,`si`.`chain` AS `chain`,`si`.`ord_id` AS `ord_id`,`si`.`inscr_id` AS `inscr_id`,`si`.`txid` AS `txid`,`si`.`index_no` AS `index_no`,`si`.`adj_index_no` AS `adj_index_no`,`si`.`num_tags` AS `num_tags`,`si`.`tag_no` AS `tag_no`,`si`.`tag_value` AS `tag_value`,`si`.`tag_guess` AS `tag_guess`,`si`.`note` AS `note`,`si`.`inscr_format` AS `inscr_format`,`tx`.`vincount` AS `total_inputs`,`tx`.`txtimedate` AS `created_on`,`tx`.`id` AS `transaction_table_pk`,`si`.`notation_id` AS `notation_id` from ((select `inscr`.`id` AS `id`,`inscr`.`chain` AS `chain`,`inscr`.`ord_id` AS `ord_id`,`inscr`.`inscr_id` AS `inscr_id`,`inscr`.`gen_trx` AS `txid`,`inscr`.`output_no` AS `index_no`,`inscr`.`adj_output_no` AS `adj_index_no`,`inscr`.`num_tags` AS `num_tags`,`o1`.`tag_no` AS `tag_no`,`o1`.`tag_value` AS `tag_value`,`o1`.`tag_guess` AS `tag_guess`,`o1`.`note` AS `note`,`o2`.`tag_guess` AS `inscr_format`,`o1`.`notation_id` AS `notation_id` from ((`inscr` join `ord_tags` `o1`) join `ord_tags` `o2`) where `inscr`.`id` = `o1`.`inscr_tb_id` and `o2`.`tag_no` = '01' and `inscr`.`id` = `o2`.`inscr_tb_id` and `o1`.`tag_no` <> '01') `si` left join `tx` on(`si`.`txid` = `tx`.`txid`)) order by `tx`.`txtimedate`,`si`.`ord_id`;
-- ----------------------------
-- View structure for non_01_tags_summary
-- ----------------------------
DROP VIEW IF EXISTS `non_01_tags_summary`;
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `non_01_tags_summary` AS select `v1`.`tag_no` AS `Tag Number`,`v1`.`notation_id` AS `Style id`,count(`v1`.`notation_id`) AS `Count`,date_format(min(`v1`.`created_on`),'%b %d %h:%i') AS `First Seen`,date_format(max(`v1`.`created_on`),'%b %d %h:%i') AS `Last Seen`,floor(count(`v1`.`ord_id`) - sum(sign(`v1`.`ord_id`) + 1) / 2) AS `Cursed`,floor(sum(sign(`v1`.`ord_id`) + 1) / 2) AS `Not Cursed` from `non_01_tags` `v1` group by 2 order by 1,3;
SET FOREIGN_KEY_CHECKS = 1;