� � CMP-3110 ~ E-Commerce Applications Development
Lecture 04
Product Variations and
User Uploads
Giving users choice
Giving users choice
Giving users choice
Giving users choice
High-level overview�
Database structure
Product Table
Attribute Table
Attribute Value
Product-attribute-value
Attributes table
Attributes table
CREATE TABLE `product_attributes` (
`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR( 50 ) NOT NULL)
ENGINE = INNODB
COMMENT = 'Product Attributes
e.g. Color, Size, etc.';
Attribute values table
Attribute values table
CREATE TABLE `product_attribute_values` (
`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR( 50 ) NOT NULL,
`attribute_id` INT NOT NULL,
INDEX ( `attribute_id` ))
ENGINE = INNODB COMMENT = 'Product Attribute Values
for example Blue, Large, etc.';
Product-attribute-value-association table
Product-attribute-value-association table
CREATE TABLE `product_attribute_value_association` (
`product_id` int(11) NOT NULL,
`attribute_id` int(11) NOT NULL,
`order` int(11) NOT NULL,
`cost_difference` double NOT NULL,
KEY `product_id` (`product_id`,`attribute_id`),
KEY `attribute_id` (`attribute_id`))
ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Association of
products and attribute values';
Product-attribute-value-association table
--Constraints for table `product_attribute_value_association`
--
ALTER TABLE `product_attribute_value_association`
ADD CONSTRAINT `product_attribute_value_association_ibfk_2`
FOREIGN KEY (`attribute_id`)
REFERENCES `product_attribute_values` (`ID`)
ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `product_attribute_value_association_ibfk_1`
FOREIGN KEY (`product_id`) REFERENCES `content` (`ID`)
ON DELETE CASCADE ON UPDATE CASCADE;
Template switching
Giving users control
Giving users control
Giving users control
Giving users control
Security considerations
Giving users control
Database changes
ALTER TABLE `content_types_products`
ADD `allow_upload` BOOL NOT NULL,
ADD `custom_text_inputs` LONGTEXT NOT NULL ;
Shopping