I’m happy to change the DB structure but I though as there could be dozens of matches on ingredients for each product I thought this was the best way of doing it. If it helps this is the structure
--
-- Table structure for table `dietary`
--
CREATE TABLE IF NOT EXISTS `dietary` (
`id`,
`product_id`,
`dietary`,
`dietary_id`,
PRIMARY KEY (`id`)
)
-- --------------------------------------------------------
--
-- Table structure for table `feeds`
--
CREATE TABLE IF NOT EXISTS `feeds` (
`product_feed_id`,
`product_name`,
`product_brand`,
`brand_name`,
`delivery_cost`,
`weight`,
`weight_id`,
`price`,
`serving`,
`image_url`,
`product_url`,
`protein_source`,
`protein_100`,
`carbs_100`,
`fat_100`,
`calories_100`,
`type`,
`protein_from`,
`next_day`,
`free_delivery`,
`stock`,
`enabled`,
`deleted`,
`aw_product_id`,
`best_seller`,
PRIMARY KEY (`product_feed_id`)
)
-- --------------------------------------------------------
--
-- Table structure for table `flavour`
--
CREATE TABLE IF NOT EXISTS `flavour` (
`id`,
`product_id`,
`dietary`,
`flavour_id`,
PRIMARY KEY (`id`)
)
-- --------------------------------------------------------
--
-- Table structure for table `ingredients`
--
CREATE TABLE IF NOT EXISTS `ingredients` (
`id`,
`product_id`,
`ingredient`,
`ingredient_id`,
PRIMARY KEY (`id`)
)
-- --------------------------------------------------------
--
-- Table structure for table `product_categories_map`
--
CREATE TABLE IF NOT EXISTS `product_categories_map` (
`id`,
`category_id`,
`product_id`,
PRIMARY KEY (`id`)
)
-- --------------------------------------------------------
--
-- Table structure for table `source`
--
CREATE TABLE IF NOT EXISTS `source` (
`id`,
`product_id`,
`dietary`,
`source_id`,
PRIMARY KEY (`id`)
)
-- --------------------------------------------------------
--
-- Table structure for table `sweeteners`
--
CREATE TABLE IF NOT EXISTS `sweeteners` (
`id`,
`product_id`,
`sweeteners`,
`sweeteners_id`,
PRIMARY KEY (`id`)
)
-- --------------------------------------------------------
--
-- Table structure for table `timing`
--
CREATE TABLE IF NOT EXISTS `timing` (
`id`,
`product_id`,
`dietary`,
`timing_id`,
PRIMARY KEY (`id`)
)