BEGIN;

CREATE TABLE `tblAttributeDefinitionGroups` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT,
  `name` varchar(100) default NULL,
  `comment` text,
  UNIQUE(`name`)
);

CREATE TABLE `tblAttributeDefinitionGroupAttributeDefinition` (
  `attrdef` INTEGER REFERENCES `tblAttributeDefinitions` (`id`) ON DELETE CASCADE,
  `attrgrp` INTEGER REFERENCES `tblAttributeGroups` (`id`) ON DELETE CASCADE,
	`sequence` INTEGER,
	`show` INTEGER,
  UNIQUE(`attrdef`, `attrgrp`)
);

CREATE TABLE `tblFolderAttributeDefinitionGroup` (
  `folder` INTEGER REFERENCES `tblFolders` (`id`) ON DELETE CASCADE,
  `attrgrp` INTEGER REFERENCES `tblAttributeGroups` (`id`) ON DELETE CASCADE,
	`sequence` INTEGER,
  UNIQUE(`folder`, `attrgrp`)
);

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

COMMIT;
