-
Notifications
You must be signed in to change notification settings - Fork 0
/
table_creation.txt
85 lines (69 loc) · 2.92 KB
/
table_creation.txt
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
CREATE TABLE KP_Products(
kpid VARCHAR(100) NOT NULL,
mspid VARCHAR(100) NOT NULL,
mspname VARCHAR(100) NOT NULL,
mspURL VARCHAR(500) NOT NULL,
PRIMARY KEY ( kpid )
);
CREATE TABLE AMZ_KP_DESC_mapping(
AMZ_KEY VARCHAR(100) NOT NULL,
AMZ_URL VARCHAR(500) NOT NULL,
kpid VARCHAR(100) NOT NULL,
productName VARCHAR(100) NOT NULL,
productColor VARCHAR(100) NOT NULL,
productModel VARCHAR(100) NOT NULL,
productModelID VARCHAR(100) NOT NULL,
productPrice VARCHAR(100) NOT NULL,
PRIMARY KEY ( AMZ_KEY )
);
CREATE TABLE FK_KP_DESC_mapping(
FK_KEY VARCHAR(100) NOT NULL,
FK_URL VARCHAR(500) NOT NULL,
kpid VARCHAR(100) NOT NULL,
productName VARCHAR(100) NOT NULL,
productColor VARCHAR(100) NOT NULL,
productModel VARCHAR(100) NOT NULL,
productModelID VARCHAR(100) NOT NULL,
productPrice VARCHAR(100) NOT NULL,
PRIMARY KEY ( FK_KEY )
);
CREATE TABLE HS18_KP_DESC_mapping(
HS18_KEY VARCHAR(100) NOT NULL,
HS18_URL VARCHAR(500) NOT NULL,
kpid VARCHAR(100) NOT NULL,
productName VARCHAR(100) NOT NULL,
productColor VARCHAR(100) NOT NULL,
productModel VARCHAR(100) NOT NULL,
productModelID VARCHAR(100) NOT NULL,
productPrice VARCHAR(100) NOT NULL,
PRIMARY KEY ( HS18_KEY )
);
CREATE TABLE IN_KP_DESC_mapping(
IN_KEY VARCHAR(500) NOT NULL,
IN_URL VARCHAR(500) NOT NULL,
kpid VARCHAR(100) NOT NULL,
productName VARCHAR(100) NOT NULL,
productColor VARCHAR(100) NOT NULL,
productModel VARCHAR(100) NOT NULL,
productModelID VARCHAR(100) NOT NULL,
productPrice VARCHAR(100) NOT NULL,
PRIMARY KEY ( IN_KEY )
);
CREATE TABLE SD_KP_DESC_mapping(
SD_KEY VARCHAR(100) NOT NULL,
SD_URL VARCHAR(500) NOT NULL,
kpid VARCHAR(100) NOT NULL,
productName VARCHAR(100) NOT NULL,
productColor VARCHAR(100) NOT NULL,
productModel VARCHAR(100) NOT NULL,
productModelID VARCHAR(100) NOT NULL,
productPrice VARCHAR(100) NOT NULL,
PRIMARY KEY ( SD_KEY )
);
SET @@group_concat_max_len = 9999999;
CREATE TABLE PRICE_mapping(
KPID VARCHAR(100) NOT NULL,
SOURCE_URL_NAME_COLOR_PRICE TEXT NOT NULL,
PRIMARY KEY ( KPID )
);
insert into PRICE_mapping select kpid, group_concat(product_attrb separator '||') from (select * from (select kpid, concat('SD', '|', SD_URL, '|', productName, '|', productColor, '|', productPrice) as product_attrb from SD_KP_DESC_mapping)t1 UNION select * from (select kpid, concat('FK', '|', FK_URL, '|', productName, '|', productColor, '|', productPrice) as product_attrb from FK_KP_DESC_mapping)t2 UNION select * from (select kpid, concat('AMZ', '|', AMZ_URL, '|', productName, '|', productColor, '|', productPrice) as product_attrb from AMZ_KP_DESC_mapping)t3 UNION select * from (select kpid, concat('HS18', '|', HS18_URL, '|', productName, '|', productColor, '|', productPrice) as product_attrb from HS18_KP_DESC_mapping)t4 UNION select * from (select kpid, concat('IN', '|', IN_URL, '|', productName, '|', productColor, '|', productPrice) as product_attrb from IN_KP_DESC_mapping)t5)t6 group by kpid;