I am working on a price comparison website using 3 API (Linkshare, commission junction and amazon). In the database, Table fields are not relevant with each other. But product names are similar to other tables.
Step 1: I want to merge all three tables and shown in single table. Is this possible?
Step 2: compare the three tables and list out the product in frontend.
note: my primary keys in three tables are: commission junction: SKU Amazon: aid LinkShare:SKUNUMBER
This is my database structure.
My table DDL structure for 3API. Amazon table structure
CREATE TABLE `amazon` ( `aid` bigint(20) NOT NULL AUTO_INCREMENT, `network` varchar(230) NOT NULL, `merchant_id` varchar(250) NOT NULL, `merchant_name` varchar(250) NOT NULL, `merchant_logo` mediumtext NOT NULL, `name` varchar(250) NOT NULL, `brand` varchar(250) NOT NULL, `asin` varchar(250) NOT NULL, `upc` varchar(150) NOT NULL, `ean` varchar(300) NOT NULL,
`image` mediumtext NOT NULL, `description` text NOT NULL, `url` mediumtext NOT NULL, `price` decimal(10,0) NOT NULL, `listprice` decimal(10,0) NOT NULL, `lowest_usedprice` decimal(10,0) NOT NULL, `shipping` varchar(130) NOT NULL, `currency` varchar(5) NOT NULL, `search_keyword` text NOT NULL, `search_maxprice` varchar(230) NOT NULL, `search_minprice` varchar(230) NOT NULL, `date` datetime NOT NULL, `catagory` varchar(255) NOT NULL, PRIMARY KEY (`aid`)) ENGINE=InnoDB AUTO_INCREMENT=68 DEFAULT CHARSET=latin1
Table structure for Commission junction.
CREATE TABLE `cjfeeds` ( `PROGRAMNAME` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `PROGRAMURL` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL, `CATALOGNAME` varchar(130) COLLATE utf8_unicode_ci DEFAULT NULL, `LASTUPDATED` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `NAME` varchar(160) COLLATE utf8_unicode_ci DEFAULT NULL, `KEYWORDS` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL, `DESCRIPTION` varchar(3000) COLLATE utf8_unicode_ci DEFAULT NULL, `SKU` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `MANUFACTURER` varchar(160) COLLATE utf8_unicode_ci DEFAULT NULL, `MANUFACTURERID` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, `UPC` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `ISBN` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
`CURRENCY` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `SALEPRICE` decimal(10,2) DEFAULT NULL, `PRICE` decimal(10,2) DEFAULT NULL, `RETAILPRICE` decimal(10,2) DEFAULT NULL,
`FROMPRICE` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `BUYURL` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL, `IMPRESSIONURL` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL, `IMAGEURL` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL, `ADVERTISERCATEGORY` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL, `THIRDPARTYID` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, `THIRDPARTYCATEGORY` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL, `AUTHOR` varchar(130) COLLATE utf8_unicode_ci DEFAULT NULL, `ARTIST` varchar(130) COLLATE utf8_unicode_ci DEFAULT NULL, `TITLE` varchar(130) COLLATE utf8_unicode_ci DEFAULT NULL, `PUBLISHER` varchar(130) COLLATE utf8_unicode_ci DEFAULT NULL, `LABEL` varchar(130) COLLATE utf8_unicode_ci DEFAULT NULL, `FORMAT` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, `SPECIAL` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `GIFT` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `PROMOTIONALTEXT` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL, `STARTDATE` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `ENDDATE` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`OFFLINE` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `ONLINE` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `INSTOCK` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
`CONDITION` varchar(11) COLLATE utf8_unicode_ci DEFAULT NULL, `WARRANTY` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL, `STANDARDSHIPPINGCOST` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`SKU`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
Table structure for linkshare:
CREATE TABLE `linkshare` ( `PRODUCTID` int(100) unsigned NOT NULL, `PRODUCTNAME` varchar(255) NOT NULL, `SKUNUMBER` varchar(200) NOT NULL, `PRIMARYCATAGRY` varchar(255) NOT NULL, `SECONDARYCATAGRY` varchar(2000) NOT NULL, `PRODUCTURL` varchar(2000) NOT NULL, `PRODUCTIMAGEURL` varchar(2000) NOT NULL, `BUYURL` varchar(2000) NOT NULL, `SHORTPRODUCTDESCRIPTION` varchar(2000) NOT NULL, `LONGPRODUCTDESCRIPTION` varchar(2000) NOT NULL, `DISCOUNT` float(8,2) unsigned NOT NULL,
`DISCOUNTTYPE` varchar(255) NOT NULL, `SALEPRICE` float(8,2) unsigned NOT NULL, `RETAILPRICE` float(8,2) unsigned NOT NULL,
`BEGINDATE` datetime NOT NULL, `ENDDATE` datetime NOT NULL, `BRAND` varchar(255) NOT NULL, `SHIPPING` int(255) unsigned NOT NULL, `KEYWORDS` varchar(500) NOT NULL, `MANUFACTURERPART` varchar(100) NOT NULL, `MANUFACTURERNAME` varchar(250) NOT NULL,
`SHIPPINGINFORMATION` varchar(50) NOT NULL, `AVAILABLITY` varchar(50) NOT NULL, `UNIVERSALPRODUCTCODE` varchar(15) NOT NULL,
`CLASSID` float(8,2) unsigned NOT NULL, `CURRENCY` varchar(3) NOT NULL, `M1` varchar(2000) NOT NULL, `PIXEL` varchar(255) NOT NULL, `MISCELLANEOUSATTRIBUTE` varchar(255) NOT NULL, `ATTRIBUTE1` varchar(255) NOT NULL, `ATTRIBUTE2` varchar(255) NOT NULL, `ATTRIBUTE3` varchar(255) NOT NULL, `ATTRIBUTE4` varchar(255) NOT NULL, `ATTRIBUTE5` varchar(255) NOT NULL, ATTRIBUTE6` varchar(255) NOT NULL, `ATTRIBUTE7` varchar(255) NOT NULL, `ATTRIBUTE8` varchar(255) NOT NULL, `ATTRIBUTE9` varchar(255) NOT NULL, `ATTRIBUTE10` varchar(255) NOT NULL, UNIQUE KEY `PRODUCTID` (`PRODUCTID`)) ENGINE=MyISAM DEFAULT CHARSET=utf8
How do I solve this and please provide me a helpful advice.
The best way for you is one stored procedure which:
Creates temporary table for comparison:
Fills this table with data from your original 3 tables:
As a result you will get the temporary table with all interesting data. This table is like a cache and should be updated every time you touch any original table.
Then you just select anything you want from
comparison_table
and join necessary original tables byorigin
andsku
. For example: