CREATE TABLE IF NOT EXISTS `CalendarEvent` ( 
`Id` int(11) NOT NULL AUTO_INCREMENT, 
`Name` VARCHAR(200)  NOT NULL,
`Code` VARCHAR(200)  NOT NULL,
`Description` TEXT  NOT NULL,
`DateStart` DATE  NOT NULL,
`HourStart` TIME  NULL,
`DateEnd` DATE  NULL,
`HourEnd` TIME  NULL,
`UserId` INT  NULL,
`Address` TEXT NULL,
`NumberPlace` INT NULL,
`AppName` VARCHAR(200)  NULL ,
  `AppId` INT  NULL ,
  `EntityName` VARCHAR(200)  NULL ,
  `EntityId` INT  NULL ,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB  DEFAULT CHARACTER SET `utf8`; 

CREATE TABLE IF NOT EXISTS `CalendarEventUser` ( 
`Id` int(11) NOT NULL AUTO_INCREMENT, 
`EventId` INT  NOT NULL,
`UserId` INT  NULL,
`Name` TEXT  NOT NULL,
`FirstName` TEXT  NOT NULL,
`Email` TEXT  NOT NULL,
`Phone` TEXT  NOT NULL,
PRIMARY KEY (`Id`),
CONSTRAINT `CalendarEvent_CalendarEventUser` FOREIGN KEY (`EventId`) REFERENCES `CalendarEvent`(`Id`)
) ENGINE=InnoDB  DEFAULT CHARACTER SET `utf8`; 