START TRANSACTION;

CREATE TABLE `tblAttributeDefinitionGroups` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(100) default NULL,
  `comment` text,
  PRIMARY KEY (`id`),
  UNIQUE(`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `tblAttributeDefinitionGroupAttributeDefinition` (
  `attrdef` int(11),
  `attrgrp` int(11),
  `sequence` double NOT NULL default '0',
	`show` int(11),
  UNIQUE(`attrdef`, `attrgrp`),
	CONSTRAINT `tblAttributeDefinitionGroupAttributeDefinition_attrdef` FOREIGN KEY (`attrdef`) REFERENCES `tblAttributeDefinitions` (`id`) ON DELETE CASCADE,
	CONSTRAINT `tblAttributeDefinitionGroupAttributeDefinition_attrgrp` FOREIGN KEY (`attrgrp`) REFERENCES `tblAttributeDefinitionGroups` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `tblFolderAttributeDefinitionGroup` (
  `folder` int(11),
  `attrgrp` int(11),
  `sequence` double NOT NULL default '0',
  UNIQUE(`folder`, `attrgrp`),
	CONSTRAINT `tblFolderAttributeDefinitionGroup_folder` FOREIGN KEY (`folder`) REFERENCES `tblFolders` (`id`) ON DELETE CASCADE,
	CONSTRAINT `tblFolderAttributeDefinitionGroup_attrgrp` FOREIGN KEY (`attrgrp`) REFERENCES `tblAttributeDefinitionGroups` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

UPDATE tblVersion set major=5, minor=2, subminor=0;

COMMIT;

