I have following table structers:
CREATE TABLE IF NOT EXISTS `campaignmaster` ( `id` INT(11) NOT NULL AUTO_INCREMENT , `propertyId` INT(11) NOT NULL , `name` VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL , `campaignCode` VARCHAR(20) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL , `propertyName` VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL , `desc` VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL , `status` ENUM('Pending','Approved','InProcess','NotApproved','Suspended','Expired') CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL , `comments` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL , `impactsForecast` ENUM('Y','N') CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT 'N' , PRIMARY KEY (`id`) ) ENGINE = MyISAM DEFAULT CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;
CREATE UNIQUE INDEX `ui_campaignmaster` ON `campaignmaster` (`propertyId` ASC, `campaignCode` ASC, `name` ASC) ; Another child table CREATE TABLE IF NOT EXISTS `campaigndetails` ( `campaignDetailsID` INT(11) NOT NULL AUTO_INCREMENT , `id` INT(11) NOT NULL DEFAULT '0' , `offerCode` VARCHAR(20) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL DEFAULT '' , `offerType` ENUM('Discount','Casino','Rate','Other') CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL , `campaignStartDate` DATE NOT NULL , `campaignEndDate` DATE NOT NULL , `occStartDate` DATE NOT NULL , `occEndDate` DATE NOT NULL , `minLOS` INT(11) NULL DEFAULT NULL , `maxLOS` INT(11) NULL DEFAULT NULL , `minAdvPurchase` INT(11) NULL DEFAULT NULL , `DOW` CHAR(25) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL , `numberofContacts` INT(11) NULL DEFAULT NULL , `expectedResponses` INT(11) NULL DEFAULT NULL , `actualResponses` INT(11) NULL DEFAULT NULL , PRIMARY KEY (`campaignDetailsID`, `id`) , CONSTRAINT `fk_campaigndetails_campaignmaster` FOREIGN KEY (`id` ) REFERENCES `campaignmaster` (`id` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = MyISAM DEFAULT CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;
CREATE UNIQUE INDEX `ui_campaigndetails` ON `campaigndetails` (`id` ASC, `offerCode` ASC, `campaignStartDate` ASC, `campaignEndDate` ASC, `occStartDate` ASC, `occEndDate` ASC) ;
CREATE INDEX `fk_campaigndetails_campaignmaster` ON `campaigndetails` (`id` ASC) ; How to define .HBM for above two tables In table 1 CREATE UNIQUE INDEX `ui_campaignmaster` ON `campaignmaster` (`propertyId` ASC, `campaignCode` ASC, `name` ASC) ;
Table 2: CREATE UNIQUE INDEX `ui_campaigndetails` ON `campaigndetails` (`id` ASC, `offerCode` ASC, `campaignStartDate` ASC, `campaignEndDate` ASC, `occStartDate` ASC, `occEndDate` ASC) ;
CREATE INDEX `fk_campaigndetails_campaignmaster` ON `campaigndetails` (`id` ASC) ;
|