Code : Tout sélectionner
//ici j'ai mis les categorie_id et categorie_detail_id pour classer le produit dans le bon menu
// il y a aussi les 2 id des variations possibles associé au produit pour pouvoir les afficher dans des combobox
- [b]produit[/b] : produit_id | produit_actif | produit_ref | produit_prix_ht | produit_tva | produit_ecotaxe | variation_id_1 | variation_id_2 | categorie_id | categorie_detail_id | mdate
//ici le position permet de classer l'ordre d'apparition des combobox
-[b]produit_variation [/b]: variation_id | position
------------------------------1-------------0
// ici c'est la table des textes des noms des variations comme taille ou couleur. C'est en plusieurs langues
- [b]produit_variation_texte[/b] : id | attribut_id | langue | titre | texte
--------------------------------1---------1----------fr------var1----couleur
//ici on ajoute des valeur pour couleur ou taille par ex M, L, XL ou rouge vert bleu
-[b]produit_variation_valeur[/b] : attribut_valeur_id | attribut_id | position | valeur_prix | valeur_prefixe
---------------------------------------1-----------------1-----------0------------5.50-------------5
//ici c'est comme tout a lh'eure cela permet d'avoir plusieurs langue mais pour les valeurs
-[b]produit_variation_valeur_texte[/b] : id | variation_valeur_id | langue | titre | texte
--------------------------------------1-------------1-------------fr-------couleur1----rouge
//ici on stocke les images, l'image qui a le plus petite position est l'image que l'on voit dans la mosaique des produits
- [b]produit_image [/b]: image_id | produit_id | position | url_thumb_img | url_full_img
-------------------------1----------------1----------0---------img/tshirt1.jpg-------------img/tshirt1_full.jpg
//ici la gestion du stock par variation par exemple variation_valeur_id_1 =>M et variation_valeur_id_2 => rouge | pour 3 couleur et 3 taille ca fait 3*3 stock différent!
- [b]produit_stock[/b] : stock_id | produit_id | unite | alerte | variation_valeur_id_1 | variation_valeur_id_2
-----------------------1-----------1------------5------1---------------1------------------------2
//ici le texte du produit en plusieurs langues
- [b]produit_texte [/b]: texte_id | produit_id | langue | titre | texte
----------------------1-----------1-----------fr---------Mon t-shirt -----ce t-shirt est magnifique
Code : Tout sélectionner
Produit référencé : TSHIRT-ADIDAS-H-ML-BLC-L et quantité achetée =2Code : Tout sélectionner
-- phpMyAdmin SQL Dump
-- version 2.11.6
-- http://www.phpmyadmin.net
--
-- Serveur: localhost
-- Généré le : Dim 21 Décembre 2008 à 00:28
-- Version du serveur: 5.0.51
-- Version de PHP: 5.2.6
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Base de données: `ecom`
--
-- --------------------------------------------------------
--
-- Structure de la table `famille`
--
CREATE TABLE `famille` (
`id_famille` int(11) NOT NULL auto_increment,
`description` text,
`categorie` VARCHAR(255),
PRIMARY KEY (`id_famille`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Contenu de la table `famille`
--
INSERT INTO `famille` (`id_famille`, `description`, `categorie`) VALUES
(1, 'T-shirt', 'Vêtement'),
(2, 'TV', 'Audio-Vidéo),
(3, 'Pull', 'Vêtement'),
(4, 'DVD', 'Audio-Vidéo);
-- --------------------------------------------------------
--
-- Structure de la table `produit`
--
CREATE TABLE `produit` (
`reference` int(11) NOT NULL,
`id_famille` int(11) default NULL,
`marque` varchar(255) NOT NULL,
`nom` varchar(50) NOT NULL,
`description` text,
`prix` float NOT NULL,
`photo` varchar(255) default NULL,
`qte_stock` int(11) NOT NULL,
PRIMARY KEY (`reference`),
KEY `ref_famille` (`id_famille`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Contenu de la table `produit`
--
INSERT INTO `produit` (`reference`, `id_famille`, `marque`, `nom`, `description`, `prix`, `photo`, `qte_stock`) VALUES
(11, 1, 'Adidas', 'T-shirt Femme Rouge taille S', NULL, 20, NULL, 10),
(12, 1, 'Adidas', 'T-shirt Homme Rouge taille L', NULL, 25, NULL, 50),
(21, 2, 'Samsung', 'HDTV LCD 94 cm (37")', NULL, 600, NULL, 10),
(22, 2, 'Panasonic', 'HDTV Plasma 107 cm (42")', NULL, 900, NULL, 10);
-- --------------------------------------------------------
--
-- Structure de la table `caracteristique`
--
CREATE TABLE `caracteristique` (
`ref_produit` int(11) NOT NULL auto_increment,
`nom_caracteristique` varchar(50) NOT NULL,
`valeur` varchar(50) NOT NULL,
UNIQUE KEY `ref_produit` (`ref_produit`,`nom_caracteristique`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=33 ;
--
-- Contenu de la table `caracteristique`
--
INSERT INTO `caracteristique` (`ref_produit`, `nom_caracteristique`, `valeur`) VALUES
(11, 'Couleur', 'Rouge'),
(11, 'Genre', 'Femme'),
(11, 'Taille', 'S'),
(12, 'Couleur', 'Rouge'),
(12, 'Genre', 'Homme'),
(12, 'Taille', 'L'),
(21, 'Format/Norme', 'HD Ready'),
(21, 'TailleDalle', '94 cm (37")'),
(21, 'TypeDalle', 'LCD'),
(22, 'Format/Norme', 'HD TV 1080p'),
(22, 'TailleDalle', '107 cm (42")'),
(22, 'TypeDalle', 'Plasma');
J'ai choisi d'associer la référence du produit et le nom de la caractéristique comme index unique parce qu'un produit ne peut être associé avec plusieurs mêmes noms de caractéristique. Par exemple, si la caractéristique est "Couleur" alors un produit "T-shirt" ne peut avoir plusieurs couleurs. C'est logique.1) est-ce juste un oubli ou c'est délibéré? parce qu'en mettant les 3 associés en unique cela devrait fonctionner, non?
La clé primaire n'est pas systématique. Elle sert simplement pour impliquer une table dans des relations avec d'autres tables. Quand la clé primaire existe, elle joue aussi le rôle d'un index unique qui veille sur l'unicité d'un enregistrement. Mais cela reste le rôle propre à un index unique.2) il n'y a pas de clé primaire dans cette table, je croyais qu'il en fallait tjs une, même si c juste "id" et en auto-incrément
En fait si un tshirt peut avoir plusieurs couleurs, c'est le client de la boutique qui la choisie ainsi que par exemple la tailleT-shirt-001, Couleur, Vert
T-shirt-001, Couleur, Rouge <-- Erreur: un produit ne doit pas avoir N couleurs à la fois
Mais on pourrait utiliser les mêmes caractéristiques pour des produits différents:
T-shirt-001, Couleur, Vert
T-shirt-001, Taille, S
T-shirt-002, Couleur, Vert
T-shirt-002, Type, S
Tous, c'est le commerçant qui décide de ce qu'il met et il peut mettre ce qu'il veut!1. Quels types de produits comptes-tu cibler?
La j'hésite entre 2 options :2. Quels sont les critères pour déterminer le prix d'un produit
alors la! avant j'avais attriburer a un produit une catégorie et sous catégorie. Mais en réfléchissant il faut pouvoir attribuer plusieurs catégorie a un produit par exemple:3. Quels sont les critères de regroupement ? types, catégories, familles, ... de produits
Code : Tout sélectionner
-- phpMyAdmin SQL Dump
-- version 2.11.6
-- http://www.phpmyadmin.net
--
-- Serveur: localhost
-- Généré le : Mer 24 Décembre 2008 à 18:35
-- Version du serveur: 5.0.51
-- Version de PHP: 5.2.6
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Base de données: `test`
--
-- --------------------------------------------------------
--
-- Structure de la table `product`
--
CREATE TABLE `product` (
`product_id` smallint(6) unsigned NOT NULL auto_increment,
`family_id` smallint(4) unsigned NOT NULL,
`active` enum('false','true') collate utf8_unicode_ci NOT NULL default 'false',
`consultation` int(11) NOT NULL,
`cdate` datetime NOT NULL,
`mdate` datetime NOT NULL,
PRIMARY KEY (`product_id`),
KEY `family_id` (`family_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4 ;
--
-- Contenu de la table `product`
--
INSERT INTO `product` (`product_id`, `family_id`, `active`, `consultation`, `cdate`, `mdate`) VALUES
(1, 1, 'true', 3, '0000-00-00 00:00:00', '0000-00-00 00:00:00'),
(2, 1, 'true', 0, '0000-00-00 00:00:00', '0000-00-00 00:00:00'),
(3, 2, 'true', 2, '0000-00-00 00:00:00', '0000-00-00 00:00:00');
-- --------------------------------------------------------
--
-- Structure de la table `product_details`
--
CREATE TABLE `product_details` (
`detail_id` mediumint(6) unsigned NOT NULL auto_increment,
`product_id` smallint(6) unsigned NOT NULL,
`reference` varchar(20) collate utf8_unicode_ci NOT NULL,
`prix_ht` decimal(10,2) NOT NULL,
`tva` decimal(10,2) NOT NULL,
`ecotaxe` decimal(10,2) NOT NULL,
`promotion` decimal(10,2) NOT NULL,
`poids` decimal(10,2) NOT NULL,
`ean` char(13) collate utf8_unicode_ci NOT NULL,
`brand` varchar(30) collate utf8_unicode_ci NOT NULL,
`waranty` smallint(6) unsigned NOT NULL,
`max_quantity` smallint(6) unsigned NOT NULL,
`stock_management` enum('false','true') collate utf8_unicode_ci NOT NULL,
`unit` smallint(3) NOT NULL,
`unit_alert` smallint(3) NOT NULL,
`available` date NOT NULL,
`max_delay` smallint(3) unsigned NOT NULL,
PRIMARY KEY (`detail_id`),
UNIQUE KEY `reference` (`reference`),
KEY `product_id` (`product_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ;
--
-- Contenu de la table `product_details`
--
INSERT INTO `product_details` (`detail_id`, `product_id`, `reference`, `prix_ht`, `tva`, `ecotaxe`, `promotion`, `poids`, `ean`, `brand`, `waranty`, `max_quantity`, `stock_management`, `unit`, `unit_alert`, `available`, `max_delay`) VALUES
(1, 1, '8ufg515gh', '20.00', '19.60', '0.00', '0.00', '200.00', '9dfdfd15d1', 'nike', 0, 20, 'true', 5, 1, '0000-00-00', 20),
(2, 1, '8ufg51fg5fd', '22.00', '19.60', '0.00', '0.00', '200.00', 'fg4f8g4fg54', 'nike', 0, 30, 'true', 10, 1, '0000-00-00', 20),
(3, 2, '5ffg45fg', '35.00', '19.60', '0.00', '0.00', '500.00', '6df5d6gf6df', 'addidas', 0, 30, 'true', 15, 1, '0000-00-00', 0),
(4, 3, '69dfd4f548', '36.00', '19.60', '0.00', '0.00', '352.00', '2fd96f5d6f5', 'ralf lauren', 0, 10, 'true', 5, 1, '0000-00-00', 0),
(5, 3, '69dfd4f549', '39.90', '19.60', '0.00', '0.00', '355.00', '4sd54d5f', 'ralf lauren', 0, 0, 'true', 9, 1, '0000-00-00', 0);
-- --------------------------------------------------------
--
-- Structure de la table `product_family`
--
CREATE TABLE `product_family` (
`family_id` smallint(4) unsigned NOT NULL auto_increment,
`category_id` smallint(4) NOT NULL,
`title` varchar(30) collate utf8_unicode_ci NOT NULL,
PRIMARY KEY (`family_id`),
KEY `category_id` (`category_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3 ;
--
-- Contenu de la table `product_family`
--
INSERT INTO `product_family` (`family_id`, `category_id`, `title`) VALUES
(1, 1, 't-shirt'),
(2, 1, 'pull');
-- --------------------------------------------------------
--
-- Structure de la table `product_images`
--
CREATE TABLE `product_images` (
`image_id` smallint(4) unsigned NOT NULL auto_increment,
`product_id` mediumint(6) unsigned NOT NULL,
`position` smallint(2) NOT NULL,
`url_thumb_image` varchar(255) collate utf8_unicode_ci NOT NULL,
`url_full_image` varchar(255) collate utf8_unicode_ci NOT NULL,
`active` enum('false','true') collate utf8_unicode_ci NOT NULL default 'false',
PRIMARY KEY (`image_id`),
KEY `variation_id` (`product_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=9 ;
--
-- Contenu de la table `product_images`
--
INSERT INTO `product_images` (`image_id`, `product_id`, `position`, `url_thumb_image`, `url_full_image`, `active`) VALUES
(4, 1, 1, 'tshirt-nike-vert-L.jpg', 'tshirt-nike-vert-L_full.jpg', 'true'),
(5, 1, 2, 'tshirt-nike-vert-S.jpg', 'tshirt-nike-vert-S_full.jpg', 'true'),
(6, 2, 0, 'tshirt-addidas-pas-de-variations.jpg', 'tshirt-addidas-pas-de-variations_full.jpg', 'true'),
(7, 3, 1, 'pull-ralfLauren-manche_courte.jpg', 'pull-ralfLauren-manche_courte_full.jpg', 'true'),
(8, 3, 2, 'pull-ralfLauren-manche_longue.jpg', 'pull-ralfLauren-manche_longue_full.jpg', 'true');
-- --------------------------------------------------------
--
-- Structure de la table `product_variations`
--
CREATE TABLE `product_variations` (
`detail_id` mediumint(6) unsigned NOT NULL,
`variation_id` mediumint(6) NOT NULL,
UNIQUE KEY `detail_id` (`detail_id`,`variation_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `product_variations`
--
INSERT INTO `product_variations` (`detail_id`, `variation_id`) VALUES
(1, 2),
(1, 5),
(2, 2),
(2, 4),
(4, 8),
(5, 7);
-- --------------------------------------------------------
--
-- Structure de la table `text_product`
--
CREATE TABLE `text_product` (
`product_id` smallint(4) unsigned NOT NULL,
`language` char(2) collate utf8_unicode_ci NOT NULL,
`title` varchar(30) collate utf8_unicode_ci NOT NULL,
`description` text collate utf8_unicode_ci NOT NULL,
`cdate` datetime NOT NULL,
`mdate` datetime NOT NULL,
UNIQUE KEY `product_id` (`product_id`,`language`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Contenu de la table `text_product`
--
INSERT INTO `text_product` (`product_id`, `language`, `title`, `description`, `cdate`, `mdate`) VALUES
(1, 'fr', 'T-shirt nike', 'Ce t-shirt est magnifique!', '0000-00-00 00:00:00', '0000-00-00 00:00:00'),
(1, 'en', 'T-shirt nike', 'This t-shirt is amazing!', '0000-00-00 00:00:00', '0000-00-00 00:00:00'),
(2, 'fr', 'T-shirt addidas', 'Ce tshirt n''est pas mal non plus', '0000-00-00 00:00:00', '0000-00-00 00:00:00'),
(3, 'fr', 'Pull ralf lauren', 'Avec ce pull vous n''aurez plus jamais froid!', '0000-00-00 00:00:00', '0000-00-00 00:00:00');
-- --------------------------------------------------------
--
-- Structure de la table `variations`
--
CREATE TABLE `variations` (
`variation_id` mediumint(6) unsigned NOT NULL auto_increment,
`title` varchar(20) collate utf8_unicode_ci NOT NULL,
`value` varchar(20) collate utf8_unicode_ci NOT NULL,
PRIMARY KEY (`variation_id`),
UNIQUE KEY `title` (`title`,`value`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=9 ;
--
-- Contenu de la table `variations`
--
INSERT INTO `variations` (`variation_id`, `title`, `value`) VALUES
(1, 'couleur', 'rouge'),
(2, 'couleur', 'vert'),
(3, 'couleur', 'bleu'),
(4, 'taille', 'S'),
(5, 'taille', 'L'),
(6, 'taille', 'XL'),
(7, 'manche', 'longue'),
(8, 'manche', 'courte');
Tu peux permettre les deux méthodes en même temps, en prévoyant un champ "prix" au niveau du produit et un champ "prix" dans l'association entre la variation et le produit (table : product_variation) car si chaque variation fait varier le prix d'un produit (comme les options de voitures par exemple) il faut fixer le prix de la variation quand celle-ci est attachée au produit. C'est logique.2. Quels sont les critères pour déterminer le prix d'un produit
La j'hésite entre 2 options :
- soit tu définie un prix de base et tu le fais varier selon les variations justement
- soit un prix par variations meme si c'est le meme prix
Pour attribuer plusieurs catégories à un produit ou plutôt à sa famille générique il faut faire une association entre les tables "product_family" et "category" qui contiendra les couples : catégorie/famille.3. Quels sont les critères de regroupement ? types, catégories, familles, ... de produits
alors la! avant j'avais attriburer a un produit une catégorie et sous catégorie. Mais en réfléchissant il faut pouvoir attribuer plusieurs catégorie a un produit par exemple:
- le tshirt peut aller dans mode homme
- ou tshirt
- ou promotion
Code : Tout sélectionner
-- =============================================================================
-- Diagram Name: ecommerce
-- Created on: 26/12/2008 18:55:31
-- Diagram Version: 1.0
-- =============================================================================
CREATE DATABASE IF NOT EXISTS `ecommerce`
CHARACTER SET utf8
COLLATE utf8_unicode_ci;
USE `ecommerce`;
SET FOREIGN_KEY_CHECKS=0;
CREATE TABLE `category` (
`category_id` smallint(6) NOT NULL,
`title` varchar(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
PRIMARY KEY(`category_id`)
)
ENGINE=INNODB
COMMENT = 'InnoDB free: 5120 kB';
CREATE TABLE `product` (
`product_id` smallint(6) UNSIGNED NOT NULL AUTO_INCREMENT,
`family_id` smallint(6) UNSIGNED NOT NULL,
`active` enum('0','1') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
`consultation` int(11) NOT NULL,
`cdate` datetime NOT NULL,
`mdate` datetime NOT NULL,
PRIMARY KEY(`product_id`),
INDEX `FK_family`(`family_id`)
)
ENGINE=INNODB;
CREATE TABLE `product_details` (
`product_ref` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`product_id` smallint(6) UNSIGNED NOT NULL,
`prix_ht` decimal(10,2) NOT NULL,
`tva` decimal(10,2) NOT NULL,
`ecotaxe` decimal(10,2) NOT NULL,
`promotion` decimal(10,2) NOT NULL,
`poids` decimal(10,2) NOT NULL,
`ean` char(13) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`brand` varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`waranty` smallint(6) UNSIGNED NOT NULL,
`max_quantity` smallint(6) UNSIGNED NOT NULL,
`stock_management` enum('0','1') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
`unit` smallint(6) NOT NULL,
`unit_alert` smallint(6) NOT NULL,
`available` datetime NOT NULL,
`max_delay` smallint(6) UNSIGNED NOT NULL,
PRIMARY KEY(`product_ref`),
INDEX `FK_product`(`product_id`)
)
ENGINE=INNODB;
CREATE TABLE `product_family` (
`family_id` smallint(6) UNSIGNED NOT NULL AUTO_INCREMENT,
`title` varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY(`family_id`)
)
ENGINE=INNODB;
CREATE TABLE `product_images` (
`image_id` smallint(6) NOT NULL,
`product_id` smallint(6) UNSIGNED NOT NULL,
`position` smallint(6) NOT NULL,
`url_thumb_image` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`url_full_image` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`active` enum('0','1') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
PRIMARY KEY(`image_id`),
INDEX `FK_product`(`product_id`)
)
ENGINE=INNODB;
CREATE TABLE `product_text` (
`product_id` smallint(6) UNSIGNED NOT NULL,
`language` char(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`title` varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`description` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`cdate` datetime NOT NULL,
`mdate` datetime NOT NULL,
PRIMARY KEY(`product_id`, `language`),
INDEX `FK_product`(`product_id`)
)
ENGINE=INNODB;
CREATE TABLE `variations` (
`variation_id` smallint(6) UNSIGNED NOT NULL AUTO_INCREMENT,
`title` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`value` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY(`variation_id`),
UNIQUE INDEX `variation_title`(`title`, `value`)
)
ENGINE=INNODB;
CREATE TABLE `product_variations` (
`product_ref` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`variation_id` smallint(6) UNSIGNED NOT NULL DEFAULT '0',
`prix_ht` decimal(10,2),
INDEX `FK_product_details`(`product_ref`),
INDEX `FK_variation`(`variation_id`),
UNIQUE INDEX `Ligne_unique`(`product_ref`, `variation_id`)
)
ENGINE=INNODB;
CREATE TABLE `category_product_family` (
`family_id` smallint(6) UNSIGNED NOT NULL DEFAULT '0',
`category_id` smallint(6) NOT NULL DEFAULT '0',
INDEX `FK_category`(`category_id`),
INDEX `FK_family`(`family_id`),
UNIQUE INDEX `Ligne_unique`(`category_id`, `family_id`)
)
ENGINE=INNODB;
ALTER TABLE `product` ADD
CONSTRAINT FOREIGN KEY (`family_id`)
REFERENCES `product_family`(`family_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ALTER TABLE `product_details` ADD
CONSTRAINT FOREIGN KEY (`product_id`)
REFERENCES `product`(`product_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ALTER TABLE `product_images` ADD
CONSTRAINT FOREIGN KEY (`product_id`)
REFERENCES `product`(`product_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ALTER TABLE `product_text` ADD
CONSTRAINT FOREIGN KEY (`product_id`)
REFERENCES `product`(`product_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ALTER TABLE `product_variations` ADD
CONSTRAINT FOREIGN KEY (`product_ref`)
REFERENCES `product_details`(`product_ref`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ALTER TABLE `product_variations` ADD
CONSTRAINT FOREIGN KEY (`variation_id`)
REFERENCES `variations`(`variation_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ALTER TABLE `category_product_family` ADD
CONSTRAINT FOREIGN KEY (`family_id`)
REFERENCES `product_family`(`family_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ALTER TABLE `category_product_family` ADD
CONSTRAINT FOREIGN KEY (`category_id`)
REFERENCES `category`(`category_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
SET FOREIGN_KEY_CHECKS=1;