-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Unique key Constraints
PostPosted: Tue Apr 12, 2011 6:19 am 
Newbie

Joined: Tue Apr 12, 2011 6:14 am
Posts: 2
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) ;


Top
 Profile  
 
 Post subject: Re: Unique key Constraints
PostPosted: Fri Apr 15, 2011 8:29 am 
Beginner
Beginner

Joined: Mon Apr 04, 2011 3:31 am
Posts: 41
can you explain what is your problem

_________________
Thanks
Niki


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.