
SET FOREIGN_KEY_CHECKS=0;

CREATE DATABASE `6265842607`
    CHARACTER SET 'latin1'
    COLLATE 'latin1_swedish_ci';

USE `6265842607`;

  
  
CREATE TABLE `absencereason` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) NOT NULL,
  `Description` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Hours` DOUBLE DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `Color` VARCHAR(16) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `address` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) NOT NULL,
  `Street` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `PostalCode` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Town` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `State` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Country` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `AddressLine1` VARCHAR(64) DEFAULT NULL,
  `AddressLine2` VARCHAR(64) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `bankaccount` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) NOT NULL,
  `BankName` VARCHAR(256) COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
  `AccountNumber` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `BankCode` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Bic` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IBAN` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `person` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `BankAccountOid` BIGINT(19) DEFAULT NULL,
  `AddressOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `FirstName` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `LastName` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Abbreviation` VARCHAR(16) COLLATE latin1_swedish_ci DEFAULT NULL,
  `DateOfBirth` DATETIME DEFAULT NULL,
  `Sex` INTEGER(10) DEFAULT NULL,
  `FamilyStatus` INTEGER(10) DEFAULT NULL,
  `Profession` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Type` INTEGER(10) DEFAULT NULL,
  `Notice` MEDIUMTEXT COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `TitleValueListEntryOid` BIGINT(19) DEFAULT NULL,
  `FunctionValueListEntryOid` BIGINT(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `RESIDENT_FK` (`AddressOid`),
  KEY `WAGES_FK` (`BankAccountOid`),
  KEY `TITLE_FK` (`TitleValueListEntryOid`),
  KEY `FUNCTION_FK` (`FunctionValueListEntryOid`),
  CONSTRAINT `FK_TITLE_VALUELISTENTRY` FOREIGN KEY (`TitleValueListEntryOid`) REFERENCES `valuelistentry` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_FUNCTION_VALUELISTENTRY` FOREIGN KEY (`FunctionValueListEntryOid`) REFERENCES `valuelistentry` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_PERSON_RESIDENT_ADDRESS` FOREIGN KEY (`AddressOid`) REFERENCES `address` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_PERSON_WAGES_BANKACCO` FOREIGN KEY (`BankAccountOid`) REFERENCES `bankaccount` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `customer` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `PersonOid` BIGINT(19) NOT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `ReferenceNumber` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `EquityContribution` DECIMAL(18,10) DEFAULT NULL,
  `Diagnosis` MEDIUMTEXT COLLATE latin1_swedish_ci DEFAULT NULL,
  `ICD10Diagnosis` MEDIUMTEXT COLLATE latin1_swedish_ci DEFAULT NULL,
  `Childs` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Notice` MEDIUMTEXT COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `TerminationValueListEntryOid` BIGINT(19) DEFAULT NULL,
  `TerminationDate` DATETIME DEFAULT NULL,
  `DebitorNumber` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsAdvisedOrAttended` TINYINT(4) DEFAULT NULL,
  `Medication` VARCHAR(1024) NULL DEFAULT NULL,
  `CostCenter` VARCHAR(128) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `CUSTOMERSMASTERDATA_FK` (`PersonOid`),
  KEY `TERMINATION_FK` (`TerminationValueListEntryOid`),
  CONSTRAINT `FK_TERMINATION_VALUELISTENTRY` FOREIGN KEY (`TerminationValueListEntryOid`) REFERENCES `valuelistentry` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_CUSTOMER_CUSTOMERS_PERSON` FOREIGN KEY (`PersonOid`) REFERENCES `person` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `absencetime` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `AbsenceReasonOid` BIGINT(19) DEFAULT NULL,
  `CustomerOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `Start` DATETIME DEFAULT NULL,
  `EndTime` DATETIME DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `EmployeeOid` BIGINT(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `CUSTOMERSABSENCES_FK` (`CustomerOid`),
  KEY `REASON_FK` (`AbsenceReasonOid`),
  KEY `EMPLOYEEABSENCES_FK` (`EmployeeOid`),
  CONSTRAINT `FK_ABSENCET_CUSTOMERS_CUSTOMER` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_ABSENCET_REASON_ABSENCER` FOREIGN KEY (`AbsenceReasonOid`) REFERENCES `absencereason` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_ABSENCET_EMPLOYEE` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `costbearer` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) NOT NULL,
  `HourlyRate` DECIMAL(18,10) DEFAULT NULL,
  `RateFactor` DECIMAL(18,10) DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `MinutesIntervall` INTEGER(10) DEFAULT NULL,
  `ReferenceNumber` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `IsCalculatingWithFactor` TINYINT(4) DEFAULT NULL,
  `IsSingleInvoicePerCustomer` bool DEFAULT TRUE,
  `ID` varchar(256) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `applicationuser` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `EmployeeOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) DEFAULT NULL,
  `LoginName` VARCHAR(64) COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
  `Password` VARCHAR(64) COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `Salt` VARCHAR(128) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `LOGIN_FK` (`EmployeeOid`),
  CONSTRAINT `FK_ASPNET_U_LOGIN_EMPLOYEE` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `employee` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `PersonOid` BIGINT(19) NOT NULL,
  `ApplicationUserOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `PersonnelNumber` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `TaxNumber` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `HealthInsurance` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsuranceNumber` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `HourlyRate` DECIMAL(18,10) DEFAULT NULL,
  `EntryDate` DATETIME DEFAULT NULL,
  `CancellationPeriod` INTEGER(10) DEFAULT NULL,
  `ProbationPeriod` INTEGER(10) DEFAULT NULL,
  `Sequence` INTEGER(10) DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `weeklyfls` DECIMAL(18,10) DEFAULT NULL,
  `weeklytotalhours` DECIMAL(18,10) DEFAULT NULL,
  `leavedays` DECIMAL(18,10) DEFAULT NULL,
  `IsQualified` TINYINT(4) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `EMPLOYEESMASTERDATA_FK` (`PersonOid`),
  KEY `LOGIN2_FK` (`ApplicationUserOid`),
  CONSTRAINT `FK_EMPLOYEE_EMPLOYEES_PERSON` FOREIGN KEY (`PersonOid`) REFERENCES `person` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_EMPLOYEE_LOGIN2_ASPNET_U` FOREIGN KEY (`ApplicationUserOid`) REFERENCES `applicationuser` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `supportconcept` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `CustomerOid` BIGINT(19) NOT NULL,
  `EmployeeOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `Conference` TINYINT(4) DEFAULT NULL,
  `Originator` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `ConferenceDate` DATETIME DEFAULT NULL,
  `ApprovalDate` DATETIME DEFAULT NULL,
  `ConsultingNeeded` TINYINT(4) DEFAULT NULL,
  `RenewalSendDate` DATETIME DEFAULT NULL,
  `RequisitionSendDate` DATETIME DEFAULT NULL,
  `SupportConceptSendDate` DATETIME DEFAULT NULL,
  `ConferenceVenue` VARCHAR(1024) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `ORIGINATOR_FK` (`EmployeeOid`),
  KEY `SUPPORT_FK` (`CustomerOid`),
  CONSTRAINT `FK_SUPPORTC_ORIGINATO_EMPLOYEE` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_SUPPORTC_SUPPORT_CUSTOMER` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `costbearer2supportconcept` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `CostBearerOid` BIGINT(19) DEFAULT NULL,
  `SupportConceptOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `HourlyRate` DECIMAL(18,10) DEFAULT NULL,
  `RateFactor` DECIMAL(18,10) DEFAULT NULL,
  `ApprovedFLS` DECIMAL(18,10) DEFAULT NULL,
  `ApprovedFLSTotal` DECIMAL(18,10) DEFAULT NULL,
  `Status` INTEGER(10) DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `RequestedStartDate` DATETIME DEFAULT NULL,
  `RequestedEndDate` DATETIME DEFAULT NULL,
  `ApprovedStartDate` DATETIME DEFAULT NULL,
  `ApprovedEndDate` DATETIME DEFAULT NULL,
  `CustomerRefenrenceNumber` VARCHAR(512) COLLATE latin1_swedish_ci DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `MonthlyPayment` DECIMAL(18,10) DEFAULT NULL,
  `PersonOid` BIGINT(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `RELATIONSHIP_41_FK` (`SupportConceptOid`),
  KEY `RELATIONSHIP_42_FK` (`CostBearerOid`),
  CONSTRAINT `FK_COSTBEAR_RELATIONS_COSTBEAR` FOREIGN KEY (`CostBearerOid`) REFERENCES `costbearer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_COSTBEAR_RELATIONS_SUPPORTC` FOREIGN KEY (`SupportConceptOid`) REFERENCES `supportconcept` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_c2s_personoid` FOREIGN KEY (`personoid`) REFERENCES `person`(`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `organisation` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `BankAccountOid` BIGINT(19) DEFAULT NULL,
  `AddressOid` BIGINT(19) DEFAULT NULL,
  `CostBearerOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Name` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `DebitorNumber` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `CostCenter` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `AccountNumber` VARCHAR(32) COLLATE latin1_swedish_ci DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `LOCATION_FK` (`AddressOid`),
  KEY `PAYMENTS_FK` (`BankAccountOid`),
  KEY `FK_ORGANISA_MAINADDRE_COSTBEAR` (`CostBearerOid`),
  CONSTRAINT `FK_ORGANISA_LOCATION_ADDRESS` FOREIGN KEY (`AddressOid`) REFERENCES `address` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_ORGANISA_MAINADDRE_COSTBEAR` FOREIGN KEY (`CostBearerOid`) REFERENCES `costbearer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_ORGANISA_PAYMENTS_BANKACCO` FOREIGN KEY (`BankAccountOid`) REFERENCES `bankaccount` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `accountingtransaction` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `SupportConceptOid` BIGINT(19) DEFAULT NULL,
  `OrganisationOid` BIGINT(19) DEFAULT NULL,
  `CustomerOid` BIGINT(19) DEFAULT NULL,
  `CostBearer2SupportConceptOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `Amount` DECIMAL(18,10) DEFAULT NULL,
  `BookingDate` DATETIME DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `CONCERNS_FK` (`SupportConceptOid`),
  KEY `CUSTOMERPAID_FK` (`CustomerOid`),
  KEY `TRANSACTION_FK` (`OrganisationOid`),
  KEY `FK_ACCOUNTI_PAYMENT_COSTBEAR` (`CostBearer2SupportConceptOid`),
  CONSTRAINT `FK_ACCOUNTI_CONCERNS_SUPPORTC` FOREIGN KEY (`SupportConceptOid`) REFERENCES `supportconcept` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_ACCOUNTI_CUSTOMERP_CUSTOMER` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_ACCOUNTI_PAYMENT_COSTBEAR` FOREIGN KEY (`CostBearer2SupportConceptOid`) REFERENCES `costbearer2supportconcept` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_ACCOUNTI_TRANSACTI_ORGANISA` FOREIGN KEY (`OrganisationOid`) REFERENCES `organisation` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `appuserfileattachmentlock` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `ApplicationUserOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `ObjectOid` BIGINT(19) DEFAULT NULL,
  `ObjectTid` INTEGER(10) DEFAULT NULL,
  `Type` INTEGER(10) DEFAULT NULL,
  `IsLocked` TINYINT(4) DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `ObjectOid_IDX` (`ObjectOid`),
  KEY `GENERALFILELOCK_FK` (`ApplicationUserOid`),
  CONSTRAINT `FK_APPUSERF_GENERALFI_APPLICAT` FOREIGN KEY (`ApplicationUserOid`) REFERENCES `applicationuser` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `organisation2person` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `PersonOid` BIGINT(19) DEFAULT NULL,
  `OrganisationOid` BIGINT(19) NOT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `ORGANISATIONORGANISATION2PERSON` (`OrganisationOid`),
  KEY `PERSONORGANISATION2PERSON_FK` (`PersonOid`),
  CONSTRAINT `FK_ORGANISA_ORGANISAT_ORGANISA` FOREIGN KEY (`OrganisationOid`) REFERENCES `organisation` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_ORGANISA_PERSONORG_PERSON` FOREIGN KEY (`PersonOid`) REFERENCES `person` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `contact` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Organisation2PersonOid` BIGINT(19) DEFAULT NULL,
  `PersonOid` BIGINT(19) DEFAULT NULL,
  `OrganisationOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `Type` INTEGER(10) DEFAULT NULL,
  `Value` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `ORGANISATIONCONTACTINFORMATION_` (`OrganisationOid`),
  KEY `ORGANISATIONPERSONCONTACT_FK` (`Organisation2PersonOid`),
  KEY `PERSONSCONTACTINFORMATION_FK` (`PersonOid`),
  CONSTRAINT `FK_CONTACT_ORGANISAT_ORGANISA` FOREIGN KEY (`Organisation2PersonOid`) REFERENCES `organisation2person` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_CONTACT_ORGANISAT_ORGANISA2` FOREIGN KEY (`OrganisationOid`) REFERENCES `organisation` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_CONTACT_PERSONSCO_PERSON` FOREIGN KEY (`PersonOid`) REFERENCES `person` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `customer2costbearer` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `CustomerOid` BIGINT(19) DEFAULT NULL,
  `CostBearerOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) DEFAULT NULL,
  `ReferenceNumber` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `COSTBEARERINCHARGE_FK` (`CustomerOid`),
  KEY `CUSTOMERSREFERNECENUMBER_FK` (`CostBearerOid`),
  CONSTRAINT `customer2costbearer_fkcb` FOREIGN KEY (`CostBearerOid`) REFERENCES `costbearer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `customer2costbearer_fkcustomer` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `customer2person` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `CustomerOid` BIGINT(19) DEFAULT NULL,
  `PersonOid` BIGINT(19) NOT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `Type` INTEGER(10) DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `CUSTOMERCUSTOMER2PERSON_FK` (`CustomerOid`),
  KEY `PERSONCUSTOMER2PERSON_FK` (`PersonOid`),
  CONSTRAINT `FK_CUSTOMER_CUSTOMERC_CUSTOMER` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_CUSTOMER_PERSONCUS_PERSON` FOREIGN KEY (`PersonOid`) REFERENCES `person` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `employee2customer` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `CustomerOid` BIGINT(19) DEFAULT NULL,
  `EmployeeOid` BIGINT(19) NOT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `EMPLOYEE2CUSTOMERCUSTOMER_FK` (`CustomerOid`),
  KEY `EMPLOYEEEMPLOYEE2CUSTOMER_FK` (`EmployeeOid`),
  CONSTRAINT `FK_EMPLOYEE_EMPLOYEE2_CUSTOMER` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_EMPLOYEE_EMPLOYEEE_EMPLOYEE` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `employee2team` (
  `TeamOid` BIGINT(19) NOT NULL,
  `EmployeeOid` BIGINT(19) NOT NULL,
  PRIMARY KEY (`TeamOid`, `EmployeeOid`),
  KEY `FK_EMPLOYEE_MEMBER2_EMPLOYEE` (`EmployeeOid`),
  CONSTRAINT `FK_EMPLOYEE_MEMBER2_EMPLOYEE` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_EMPLOYEE_MEMBER_TEAM` FOREIGN KEY (`TeamOid`) REFERENCES `team` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `fileattachment` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) NOT NULL,
  `ObjectOid` BIGINT(19) DEFAULT NULL,
  `ObjectTid` INTEGER(10) DEFAULT NULL,
  `Type` INTEGER(10) DEFAULT NULL,
  `Path` VARCHAR(512) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `Data` MEDIUMBLOB,
  `BeWoFolderOid` BIGINT(19) NULL,
  PRIMARY KEY (`Oid`),
  KEY `ObjectOid_IDX` (`ObjectOid`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `ingroup` (
  `UserGroupOid` BIGINT(19) NOT NULL,
  `ApplicationUserOid` BIGINT(19) NOT NULL,
  PRIMARY KEY (`UserGroupOid`, `ApplicationUserOid`),
  KEY `FK_INGROUP_INGROUP2_APPLICAT` (`ApplicationUserOid`),
  CONSTRAINT `FK_INGROUP_INGROUP2_APPLICAT` FOREIGN KEY (`ApplicationUserOid`) REFERENCES `applicationuser` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_INGROUP_INGROUP_USERGROU` FOREIGN KEY (`UserGroupOid`) REFERENCES `usergroup` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `query` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) DEFAULT NULL,
  `Type` INTEGER(10) DEFAULT NULL,
  `Title` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Sql` VARCHAR(2048) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `UserGroupOids` VARCHAR(1024) DEFAULT NULL,
  `ReportTypeName` VARCHAR(1024) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `parameter` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `QueryOid` BIGINT(19) NOT NULL,
  `Tid` INTEGER(10) DEFAULT NULL,
  `Name` VARCHAR(512) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Type` INTEGER(10) DEFAULT NULL,
  `DbType` INTEGER(10) DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `QUERYPARAMETER_FK` (`QueryOid`),
  CONSTRAINT `FK_PARAMETE_QUERYPARA_QUERY` FOREIGN KEY (`QueryOid`) REFERENCES `query` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `reportparameter` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) DEFAULT NULL,
  `Type` INTEGER(10) DEFAULT NULL,
  `Value` VARCHAR(2048) COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `resource` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) NOT NULL,
  `Name` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Description` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Color` VARCHAR(9) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `resourcebookingsequence` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `ResourceOid` BIGINT(19) NOT NULL,
  `EmployeeOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) DEFAULT NULL,
  `FrequencyType` INTEGER(10) NOT NULL,
  `RepeatInterval` INTEGER(10) DEFAULT NULL,
  `SequenceEndDate` DATETIME DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `RecurrenceInfo` MEDIUMTEXT NULL,
  PRIMARY KEY (`Oid`),
  KEY `FK_RESOURCE_EMPLOYEER_EMPLOYEE` (`EmployeeOid`),
  KEY `FK_RESOURCE_RESOURCER_RESOURCE` (`ResourceOid`),
  CONSTRAINT `FK_RESOURCE_EMPLOYEER_EMPLOYEE` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_RESOURCE_RESOURCER_RESOURCE` FOREIGN KEY (`ResourceOid`) REFERENCES `resource` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `resourcebooking` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `ResourceBookingSequenceOid` BIGINT(19) DEFAULT NULL,
  `EmployeeOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `SequencePosition` INTEGER(10) DEFAULT NULL,
  `StartDateTime` DATETIME DEFAULT NULL,
  `EndDateTime` DATETIME DEFAULT NULL,
  `IsDeleted` TINYINT(4) NOT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `RecurrenceInfo` MEDIUMTEXT NULL,
  PRIMARY KEY (`Oid`),
  KEY `EMPLOYEE2SINGLEBOOKING_FK` (`EmployeeOid`),
  KEY `FK_RESOURCE_DETAILORR_RESOURCE` (`ResourceBookingSequenceOid`),
  CONSTRAINT `FK_RESOURCE_DETAILORR_RESOURCE` FOREIGN KEY (`ResourceBookingSequenceOid`) REFERENCES `resourcebookingsequence` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_RESOURCE_EMPLOYEE2_EMPLOYEE` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `usergroup` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `ParentGroupOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) DEFAULT NULL,
  `Name` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Description` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `PARENT_FK` (`ParentGroupOid`),
  CONSTRAINT `FK_USERGROU_PARENT_USERGROU` FOREIGN KEY (`ParentGroupOid`) REFERENCES `usergroup` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `rightrelation` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `ApplicationUserOid` BIGINT(19) DEFAULT NULL,
  `UserGroupOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) DEFAULT NULL,
  `RightType` BIGINT(19) DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `EXTRARIGHTSGRANTED_FK` (`ApplicationUserOid`),
  KEY `RIGHTGRANTED_FK` (`UserGroupOid`),
  CONSTRAINT `FK_RIGHTREL_EXTRARIGH_ASPNET_U` FOREIGN KEY (`ApplicationUserOid`) REFERENCES `applicationuser` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_RIGHTREL_RIGHTGRAN_USERGROU` FOREIGN KEY (`UserGroupOid`) REFERENCES `usergroup` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `servicecategory` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) NOT NULL,
  `Name` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Abbreviation` VARCHAR(16) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Percentage` DOUBLE DEFAULT NULL,
  `Billable` TINYINT(4) DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `BillableFixedAmount` DECIMAL(18,10) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `servicedescription` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `ServiceCategoryOid` BIGINT(19) NOT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `Name` VARCHAR(512) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Abbreviation` VARCHAR(16) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `BillableFixedAmount` DECIMAL(18,10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `CATEGORISATION_FK` (`ServiceCategoryOid`),
  CONSTRAINT `FK_SERVICED_CATEGORIS_SERVICEC` FOREIGN KEY (`ServiceCategoryOid`) REFERENCES `servicecategory` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';


CREATE TABLE `servicerecordgroup` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) DEFAULT NULL,
  `CustomerCount` INTEGER(10) DEFAULT NULL,
  `EmployeeCount` INTEGER(10) DEFAULT NULL,
  `RoundedDuration` DECIMAL(18,10) DEFAULT NULL,
  `StartDate` DATETIME DEFAULT NULL,
  `EndDate` DATETIME DEFAULT NULL,
  `Notice` MEDIUMTEXT DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `servicerecord` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `CustomerOid` BIGINT(19) DEFAULT NULL,
  `EmployeeOid` BIGINT(19) NOT NULL,
  `SupportConceptOid` BIGINT(19) DEFAULT NULL,
  `CostBearer2SupportConceptOid` BIGINT(19) DEFAULT NULL,
  `ServiceDescriptionOid` BIGINT(19) NOT NULL,
  `Tid` INTEGER(10) DEFAULT NULL,
  `StartDate` DATETIME DEFAULT NULL,
  `EndDate` DATETIME DEFAULT NULL,
  `IP` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `RoundedDuration` DECIMAL(18,10) DEFAULT NULL,
  `Notice` MEDIUMTEXT COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `GroupPersonCount` INTEGER(10) DEFAULT NULL,
  `GroupEmployeeCount` INTEGER(10) DEFAULT NULL,
  `GroupRoundedDuration` DECIMAL(18,10) DEFAULT NULL,
  `GroupOid` BIGINT(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `COSTBEARING_FK` (`CostBearer2SupportConceptOid`),
  KEY `DESCRIPTION_FK` (`ServiceDescriptionOid`),
  KEY `DONEWORK_FK` (`SupportConceptOid`),
  KEY `FK_CUSTOMER_CUSTOMER2_CUSTOMER` (`CustomerOid`),
  KEY `FK_EMPLOYEE_EMPLOYEE2_EMPLOYEE` (`EmployeeOid`),
  KEY `FK_GROUP` (`GroupOid`),
  CONSTRAINT `FK_CUSTOMER_CUSTOMER2_CUSTOMER` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_EMPLOYEE_EMPLOYEE2_EMPLOYEE` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_SERVICEP_DESCRIPTI_SERVICED` FOREIGN KEY (`ServiceDescriptionOid`) REFERENCES `servicedescription` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_SERVICER_COSTBEARI_COSTBEAR` FOREIGN KEY (`CostBearer2SupportConceptOid`) REFERENCES `costbearer2supportconcept` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_SERVICER_DONEWORK_SUPPORTC` FOREIGN KEY (`SupportConceptOid`) REFERENCES `supportconcept` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_GROUP` FOREIGN KEY (`GroupOid`) REFERENCES `servicerecordgroup` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `settings` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) DEFAULT NULL,
  `ObjectOid` BIGINT(19) DEFAULT NULL,
  `ObjectTid` INTEGER(10) DEFAULT NULL,
  `Type` INTEGER(10) DEFAULT NULL,
  `Value` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `ObjectOid_IDX` (`ObjectOid`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `team` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `EmployeeOid` BIGINT(19) NOT NULL,
  `Tid` INTEGER(10) DEFAULT NULL,
  `Name` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `IsActive2` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `LEADER_FK` (`EmployeeOid`),
  CONSTRAINT `FK_TEAM_LEADER_EMPLOYEE` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `valuelistentry` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) NOT NULL,
  `Type` INTEGER(10) DEFAULT NULL,
  `Value` VARCHAR(2048) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Abbreviation` VARCHAR(16) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `ParentOid` BIGINT(19) NULL,
  PRIMARY KEY (`Oid`),
  KEY `PARENT_FK` (`ParentOid`),
  CONSTRAINT `FK_PARENT_VALUELISTITEM` FOREIGN KEY (`ParentOid`) REFERENCES `valuelistentry` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `valuelistentry2object` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `ValueListEntryOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `ObjectOid` BIGINT(19) DEFAULT NULL,
  `ObjectTid` INTEGER(10) DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `REFERSTO_FK` (`ValueListEntryOid`),
  KEY `ObjectOid_IDX` (`ObjectOid`),
  CONSTRAINT `FK_VALUELIS_REFERSTO_VALUELIS` FOREIGN KEY (`ValueListEntryOid`) REFERENCES `valuelistentry` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `mail` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) NOT NULL,
  `SenderOid` BIGINT(19) DEFAULT NULL,
  `Notice` MEDIUMTEXT COLLATE latin1_swedish_ci DEFAULT NULL,
  `Message` MEDIUMTEXT COLLATE latin1_swedish_ci DEFAULT NULL,
  `Subject` MEDIUMTEXT COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `SENDER_FK` (`SenderOid`),
  CONSTRAINT `FK_SENDER_OID` FOREIGN KEY (`SenderOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `mail2receiver` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) NOT NULL,
  `MailOid` BIGINT(19) NOT NULL,
  `ReceiverOid` BIGINT(19) DEFAULT NULL,
  `ReceiverEMailAddress` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Status` TINYINT(4) DEFAULT NULL,
  `Priority` TINYINT(4) DEFAULT NULL,
  `IsBlind` TINYINT(4) DEFAULT NULL,
  `Notice` MEDIUMTEXT COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `RECEIVER_FK` (`ReceiverOid`),
  KEY `Mail_FK` (`MailOid`),
  CONSTRAINT `FK_RECEIVER_OID` FOREIGN KEY (`ReceiverOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_MAIL_OID` FOREIGN KEY (`MailOid`) REFERENCES `mail` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `followup` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) NOT NULL,
  `ObjectOid` BIGINT(19) DEFAULT NULL,
  `ObjectTid` INTEGER(10) DEFAULT NULL,
  `EmployeeOid` BIGINT(19) NOT NULL,
  `ResponsibleOid` BIGINT(19) NOT NULL,
  `Notice` MEDIUMTEXT COLLATE latin1_swedish_ci DEFAULT NULL,
  `ExpirationDate` DATETIME DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `IsHandled` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `EMPLOYEE_FK` (`EmployeeOid`),
  KEY `RESPONSIBLE_FK` (`ResponsibleOid`),
  KEY `ObjectOid_IDX` (`ObjectOid`),
  CONSTRAINT `FK_EMPLOYEE_OID` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_RESPONSIBLE_OID` FOREIGN KEY (`ResponsibleOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `login` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `LoginName` VARCHAR(64) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Password` VARCHAR(64) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IPAddress` VARCHAR(32) COLLATE latin1_swedish_ci DEFAULT NULL,
  `HostName` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Referrer` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Browser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Notice` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `LoginDate` DATETIME DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `LoginNameIdx` (`LoginName`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `costrateperiod` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `ObjectOid` BIGINT(19) DEFAULT NULL,
  `ObjectTid` INTEGER(10) DEFAULT NULL,
  `CostRateType` INTEGER(10) DEFAULT NULL,
  `CostRateValue` DECIMAL(18,10) DEFAULT NULL,
  `StartDate` DATETIME DEFAULT NULL,
  `EndDate` DATETIME DEFAULT NULL,
  `Notice` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `ValueListEntryOid` BIGINT(19) DEFAULT NULL,
  `UnitName` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `ObjectOid_IDX` (`ObjectOid`),
  CONSTRAINT `fk_crp_valuelistentryoid`
  FOREIGN KEY (`ValueListEntryOid`)
    REFERENCES `valuelistentry`(`Oid`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';


CREATE TABLE `diagnosis2customer` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) NOT NULL,
  `CustomerOid` BIGINT(19) DEFAULT NULL,
  `ICD10DiagnosisCode` VARCHAR(128) NOT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `DIAGNOSIS2CUSTOMERCUSTOMER_FK` (`CustomerOid`),
  CONSTRAINT `FK_DIAGNOSIS_DIAGNOSIS2_CUSTOMER` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `timesheet` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `SupportConceptOid` BIGINT(19) DEFAULT NULL,
  `CostBearer2SupportConceptOid` BIGINT(19) DEFAULT NULL,
  `Tid` INTEGER(10) DEFAULT NULL,
  `CreationDate` DATETIME DEFAULT NULL,
  `SignDate` DATETIME DEFAULT NULL,
  `Notice` MEDIUMTEXT COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `TIMESHEET_SUPPORTCONCEPT_FK` (`SupportConceptOid`),
  KEY `TIMESHEET_CB2SUPPORTCONCEPT_FK` (`CostBearer2SupportConceptOid`),
  CONSTRAINT `FK_TIMESHEET_CB2SUPPORTCONCEPT` FOREIGN KEY (`CostBearer2SupportConceptOid`) REFERENCES `costbearer2supportconcept` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_TIMESHEET_SUPPORTCONCEPT` FOREIGN KEY (`SupportConceptOid`) REFERENCES `supportconcept` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `mandator` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) NOT NULL,
  `Name` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `ClientId` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Street` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `PostalCode` VARCHAR(128) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Town` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `State` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Country` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `BeWoClientType` BIGINT(19) DEFAULT NULL,
  `Settings` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `placement` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Tid` INTEGER(10) NOT NULL,
  `ObjectiveValueListEntryOid` BIGINT(19) DEFAULT NULL,  
  `CustomerOid` BIGINT(19) DEFAULT NULL,
  `PlacementDate` DATETIME DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `CUSTOMER_FK` (`CustomerOid`),
  KEY `OBJECTIVE_FK` (`ObjectiveValueListEntryOid`),
  CONSTRAINT `FK_PLACEMENT_CUSTOMER` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_OBJECTIVE_VALUELISTENTRY` FOREIGN KEY (`ObjectiveValueListEntryOid`) REFERENCES `valuelistentry` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE  TABLE `InvoiceBase` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `SupportConceptOid` BIGINT(19) NULL DEFAULT NULL ,
  `CostBearer2SupportConceptOid` BIGINT(19) NULL DEFAULT NULL ,
  `RecipientCustomerOid` BIGINT(19) NULL DEFAULT NULL ,
  `RecipientOrganisationOid` BIGINT(19) NULL DEFAULT NULL ,
  `RecipientPersonOid` BIGINT(19) NULL DEFAULT NULL ,
  `RecipientCostBearerOid` BIGINT(19) NULL DEFAULT NULL ,
  `RecipientAddressOid` BIGINT(19) NULL DEFAULT NULL ,
  `RecipientOrganisation` VARCHAR(256) NULL DEFAULT NULL ,
  `RecipientDivision` VARCHAR(45) NULL DEFAULT NULL ,
  `RecipientPersonFirstName` VARCHAR(256) NULL DEFAULT NULL ,
  `RecipientPersonLastName` VARCHAR(256) NULL DEFAULT NULL ,
  `InvoiceNumber` VARCHAR(256) NULL DEFAULT NULL ,
  `InvoiceTitle` VARCHAR(256) NULL DEFAULT NULL ,
  `InvoiceDate` DATETIME NULL DEFAULT NULL ,
  `AccountingPeriodStart` DATETIME NULL DEFAULT NULL ,
  `AccountingPeriodEnd` DATETIME NULL DEFAULT NULL ,
  `SenderFirstName` VARCHAR(256) NULL DEFAULT NULL ,
  `SenderLastName` VARCHAR(256) NULL DEFAULT NULL ,
  `SenderDivision` VARCHAR(256) NULL DEFAULT NULL ,
  `SenderOrganisation` VARCHAR(256) NULL DEFAULT NULL ,
  `SenderAddressOid` BIGINT(19) NULL DEFAULT NULL ,
  `CustomerReferenceNumber` VARCHAR(256) NULL DEFAULT NULL ,
  `CreatorFirstName` VARCHAR(256) NULL DEFAULT NULL ,
  `CreatorLastName` VARCHAR(256) NULL DEFAULT NULL ,
  `DueDate` DATETIME NULL DEFAULT NULL ,
  `Type` INTEGER(10) NULL DEFAULT NULL ,
  `IsPaid` TINYINT(4) NULL DEFAULT NULL ,
  `IsActive` TINYINT(4) NULL DEFAULT NULL ,
  `Notice` VARCHAR(4000) NULL DEFAULT NULL ,
  `InsTs` DATETIME NULL DEFAULT NULL ,
  `InsUser` VARCHAR(256) NULL DEFAULT NULL ,
  `Version` BIGINT(19) NULL DEFAULT NULL ,
  `UdpUser` VARCHAR(256) NULL DEFAULT NULL ,
  `SystemEntryID` INT(10) NULL DEFAULT NULL ,
  `DunningLetterCount` INT(10) NULL DEFAULT NULL ,
  `XMLData` VARCHAR(8000) NULL DEFAULT NULL ,
  `IsPrinted` bool DEFAULT FALSE,
  PRIMARY KEY (`Oid`) ,
  INDEX `FK_IN_PER` (`RecipientPersonOid` ASC) ,
  INDEX `FK_IN_CUS` (`RecipientCustomerOid` ASC) ,
  INDEX `FK_IN_ORG` (`RecipientOrganisationOid` ASC) ,
  INDEX `FK_IN_CB` (`RecipientCostBearerOid` ASC) ,
  INDEX `FK_IN_SC` (`SupportConceptOid` ASC) ,
  INDEX `FK_IN_ADD_RE` (`RecipientAddressOid` ASC) ,
  INDEX `FK_IN_ADD_SE` (`SenderAddressOid` ASC) ,
  INDEX `FK_IN_SC2CB` (`CostBearer2SupportConceptOid` ASC) ,
  CONSTRAINT `FK_IN_PER`
    FOREIGN KEY (`RecipientPersonOid` )
    REFERENCES `person` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `FK_IN_CUS`
    FOREIGN KEY (`RecipientCustomerOid` )
    REFERENCES `customer` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `FK_IN_ORG`
    FOREIGN KEY (`RecipientOrganisationOid` )
    REFERENCES `organisation` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `FK_IN_CB`
    FOREIGN KEY (`RecipientCostBearerOid` )
    REFERENCES `costbearer` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `FK_IN_SC`
    FOREIGN KEY (`SupportConceptOid` )
    REFERENCES `supportconcept` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `FK_IN_ADD_RE`
    FOREIGN KEY (`RecipientAddressOid` )
    REFERENCES `address` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `FK_IN_ADD_SE`
    FOREIGN KEY (`SenderAddressOid` )
    REFERENCES `address` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `FK_IN_SC2CB`
    FOREIGN KEY (`CostBearer2SupportConceptOid` )
    REFERENCES `costbearer2supportconcept` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
COLLATE = latin1_swedish_ci;

CREATE  TABLE `InvoiceItem` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `InvoiceBaseOid` BIGINT(19) NULL DEFAULT NULL ,
  `ItemPeriodStart` DATETIME NULL DEFAULT NULL ,
  `ItemPeriodEnd` DATETIME NULL DEFAULT NULL ,
  `ItemDescription` VARCHAR(256) NULL DEFAULT NULL ,
  `UnitCount` DECIMAL(12,4) DEFAULT NULL,
  `UnitDescription` VARCHAR(45) NULL DEFAULT NULL ,
  `AmountPerUnit` DECIMAL(18,10) NULL DEFAULT NULL ,
  `AmountTotal` DECIMAL(18,10) NULL DEFAULT NULL ,
  `IsActive` VARCHAR(45) NULL DEFAULT NULL ,
  `Notice` VARCHAR(1024) NULL DEFAULT NULL ,
  `InsTs` DATETIME NULL DEFAULT NULL ,
  `InsUser` VARCHAR(256) NULL DEFAULT NULL ,
  `Version` BIGINT(19) NULL DEFAULT NULL ,
  `UdpUser` VARCHAR(256) NULL DEFAULT NULL ,
  `SystemEntryID` INT(10) NULL DEFAULT NULL ,
  `SupportConceptApprovalPeriodOid` BIGINT(19) DEFAULT NULL ,
  `ServiceRecordOid` BIGINT(19) DEFAULT NULL ,
	`IsBillable` bool DEFAULT TRUE,
	`NotBillableType` bool,
	`ServiceInvoicePeriodOid` bigint(19),
	`RateFactor` decimal(18,10),
	`GrossAmountTotal` decimal(18,10),
  PRIMARY KEY (`Oid`) ,
  INDEX `FK_INIT_INB` (`InvoiceBaseOid` ASC) ,
  CONSTRAINT `FK_INIT_INB` FOREIGN KEY (`InvoiceBaseOid` ) REFERENCES `InvoiceBase` (`Oid` ) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_invoiceitem_scapprovalperiodoid` FOREIGN KEY (`SupportConceptApprovalPeriodOid`) REFERENCES `supportconceptapprovalperiod`(`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
	CONSTRAINT `fk_invoiceitem_ServiceRecordOid` FOREIGN KEY (`ServiceRecordOid`) REFERENCES `ServiceRecord`(`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
	CONSTRAINT `fk_ii_sp` FOREIGN KEY (`serviceinvoiceperiodoid`) REFERENCES `serviceinvoiceperiod`(`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
COLLATE = latin1_swedish_ci;


CREATE  TABLE `invoice` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `SupportConceptOid` BIGINT(19) NULL DEFAULT NULL ,
  `OrganisationOid` BIGINT(19) NULL DEFAULT NULL ,
  `InvoicingPeriodStart` DATETIME NULL DEFAULT NULL ,
  `InvoicingPeriodEnd` DATETIME NULL DEFAULT NULL ,
  `Amount` DECIMAL(18,10) NULL DEFAULT NULL ,
  `InvoiceDate` DATETIME NULL DEFAULT NULL ,
  `InvoiceNumber` VARCHAR(256) NULL DEFAULT NULL ,
  `PaidDate` DATETIME NULL DEFAULT NULL ,
  `Notice` VARCHAR(1024) NULL DEFAULT NULL ,
  `IsActive` TINYINT(4) NULL DEFAULT NULL ,
  `InsTs` DATETIME NULL DEFAULT NULL ,
  `InsUser` VARCHAR(256) NULL DEFAULT NULL ,
  `UpdUser` VARCHAR(256) NULL DEFAULT NULL ,
  `Version` BIGINT(19) NULL DEFAULT NULL ,
  `SystemEntryID` INT(10) NULL DEFAULT NULL ,
  PRIMARY KEY (`Oid`) ,
  INDEX `invoice2organisation` (`OrganisationOid` ASC) ,
  INDEX `invoce2supportconcept` (`SupportConceptOid` ASC) ,
  CONSTRAINT `invoice2organisation`
    FOREIGN KEY (`OrganisationOid` )
    REFERENCES `organisation` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `invoce2supportconcept`
    FOREIGN KEY (`SupportConceptOid` )
    REFERENCES `supportconcept` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
COLLATE = latin1_swedish_ci;

CREATE  TABLE IF NOT EXISTS `SettlementInvoice` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `InvoiceBaseOid` BIGINT(19) NULL DEFAULT NULL ,
  `ApprovedFLS` DECIMAL(18,10) NULL DEFAULT NULL ,
  `RecordedBillableFLSNetto` DECIMAL(18,10) NULL DEFAULT NULL ,
  `RecordedBillableFLSNotBillableOutOfApprovedSpan` DECIMAL(18,10) NULL DEFAULT NULL ,
  `RecordedBillableFLSNotBillableCustomerAbsent` DECIMAL(18,10) NULL DEFAULT NULL ,
  `AmountRecordedBillableFLS` DECIMAL(18,10) NULL DEFAULT NULL ,
  `AmountRateFactor` DECIMAL(18,10) NULL DEFAULT NULL ,
  `AmountAdvancedPayments` DECIMAL(18,10) NULL DEFAULT NULL ,
  `Claim` DECIMAL(18,10) NULL DEFAULT NULL ,
  `IsActive` VARCHAR(45) NULL DEFAULT NULL ,
  `Notice` VARCHAR(1024) NULL DEFAULT NULL ,
  `InsTs` DATETIME NULL DEFAULT NULL ,
  `InsUser` VARCHAR(256) NULL DEFAULT NULL ,
  `Version` BIGINT(19) NULL DEFAULT NULL ,
  `UdpUser` VARCHAR(256) NULL DEFAULT NULL ,
  `SystemEntryID` INT(10) NULL DEFAULT NULL ,
  `ApprovalNoticeDate` DATETIME NULL DEFAULT NULL ,
  `RecordedBillableFLSBrutto` DECIMAL(18,10) NULL DEFAULT NULL ,
  `AmountWithRateFactor` DECIMAL(18,10) NULL DEFAULT NULL ,
  `ApprovedFLSWithActualHourlyRate` DECIMAL(18,10) NULL DEFAULT NULL ,
  `ApprovedFLSWithOldHourlyRate` DECIMAL(18,10) NULL DEFAULT NULL ,
  `HourlyRateOldEndDate` DATETIME NULL DEFAULT NULL ,
  `HourlyRateNewStartDate` DATETIME NULL DEFAULT NULL ,
  `HourlyRateNew` DECIMAL(18,10) NULL DEFAULT NULL ,
  `AmountTotalAdvancedPaidWithOldHourlyRate` DECIMAL(18,10) NULL DEFAULT NULL ,
  `HourlyRateOld` DECIMAL(18,10) NULL DEFAULT NULL ,
  `AmountTotalAdvancedPaidWithNewHourlyRate` DECIMAL(18,10) NULL DEFAULT NULL ,
  PRIMARY KEY (`Oid`) ,
  INDEX `FK_SI_IB` (`InvoiceBaseOid` ASC) ,
  CONSTRAINT `FK_SI_IB`
    FOREIGN KEY (`InvoiceBaseOid` )
    REFERENCES `InvoiceBase` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
COLLATE = latin1_swedish_ci;

ALTER TABLE `person` ADD COLUMN `InvoiceAddressOid` BIGINT(19) NULL DEFAULT NULL  AFTER `AddressOid` , 
  ADD CONSTRAINT `FK_PERSON_ADDRESS_INVOICE`
  FOREIGN KEY (`InvoiceAddressOid` )
  REFERENCES `address` (`Oid` )
  ON DELETE NO ACTION
  ON UPDATE NO ACTION
, ADD INDEX `FK_PERSON_ADDRESS_INVOICE` (`InvoiceAddressOid` ASC) ;


ALTER TABLE `organisation` ADD COLUMN `InvoiceAddressOid` BIGINT(19) NULL DEFAULT NULL  AFTER `AddressOid` , 
  ADD CONSTRAINT `FK_ORG_ADD_INV`
  FOREIGN KEY (`InvoiceAddressOid` )
  REFERENCES `address` (`Oid` )
  ON DELETE NO ACTION
  ON UPDATE NO ACTION
, ADD INDEX `FK_ORG_ADD_INV` (`InvoiceAddressOid` ASC) ;

ALTER TABLE `contact` ADD COLUMN `InvoiceBaseRecipientOid` BIGINT(19) NULL DEFAULT NULL  AFTER `OrganisationOid` , ADD COLUMN `InvoiceBaseSenderOid` BIGINT(19) NULL DEFAULT NULL  AFTER `PersonOid` , 
  ADD CONSTRAINT `FK_CONTACT_INVOICEBASE_RECIPIENT`
  FOREIGN KEY (`InvoiceBaseRecipientOid` )
  REFERENCES `InvoiceBase` (`Oid` )
  ON DELETE NO ACTION
  ON UPDATE NO ACTION, 
  ADD CONSTRAINT `FK_CONTACT_INVOICEBASE_SENDER`
  FOREIGN KEY (`InvoiceBaseSenderOid` )
  REFERENCES `InvoiceBase` (`Oid` )
  ON DELETE NO ACTION
  ON UPDATE NO ACTION
, ADD INDEX `FK_CONTACT_INVOICEBASE_RECIPIENT` (`InvoiceBaseRecipientOid` ASC) 
, ADD INDEX `FK_CONTACT_INVOICEBASE_SENDER` (`InvoiceBaseSenderOid` ASC) ;




CREATE  TABLE IF NOT EXISTS `AssessmentSheetCategory` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `Description` VARCHAR(512) NULL DEFAULT NULL ,
  `IsActive` VARCHAR(45) NULL DEFAULT NULL ,
  `Notice` VARCHAR(1024) NULL DEFAULT NULL ,
  `InsTs` DATETIME NULL DEFAULT NULL ,
  `InsUser` VARCHAR(256) NULL DEFAULT NULL ,
  `Version` BIGINT(19) NULL DEFAULT NULL ,
  `UdpUser` VARCHAR(256) NULL DEFAULT NULL ,
  `SystemEntryID` INT(10) NULL DEFAULT NULL ,
  `Position` INT(11) NULL DEFAULT NULL,
  PRIMARY KEY (`Oid`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
COLLATE = latin1_swedish_ci;


CREATE  TABLE IF NOT EXISTS `AssessmentSheetValue` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `Sign` VARCHAR(5) NULL DEFAULT NULL ,
  `Color` VARCHAR(45) NULL DEFAULT NULL ,
  `ShortcutKey` VARCHAR(5) NULL DEFAULT NULL ,
  `Description` VARCHAR(512) NULL DEFAULT NULL ,
  `IsActive` VARCHAR(45) NULL DEFAULT NULL ,
  `Notice` VARCHAR(1024) NULL DEFAULT NULL ,
  `InsTs` DATETIME NULL DEFAULT NULL ,
  `InsUser` VARCHAR(256) NULL DEFAULT NULL ,
  `Version` BIGINT(19) NULL DEFAULT NULL ,
  `UdpUser` VARCHAR(256) NULL DEFAULT NULL ,
  `SystemEntryID` INT(10) NULL DEFAULT NULL ,
  `Position` INT(11) NULL DEFAULT NULL,
  PRIMARY KEY (`Oid`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
COLLATE = latin1_swedish_ci;


CREATE  TABLE IF NOT EXISTS `AssessmentSheetEntry` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `CustomerOid` BIGINT(19) NOT NULL ,
  `Day` DATETIME NULL DEFAULT NULL ,
  `AssessmentSheetCategoryOid` BIGINT(19) NOT NULL ,
  `AssessmentSheetValueOid` BIGINT(19) NOT NULL ,
  `IsActive` VARCHAR(45) NULL DEFAULT NULL ,
  `Notice` VARCHAR(1024) NULL DEFAULT NULL ,
  `InsTs` DATETIME NULL DEFAULT NULL ,
  `InsUser` VARCHAR(256) NULL DEFAULT NULL ,
  `Version` BIGINT(19) NULL DEFAULT NULL ,
  `UdpUser` VARCHAR(256) NULL DEFAULT NULL ,
  `SystemEntryID` INT(10) NULL DEFAULT NULL ,
  PRIMARY KEY (`Oid`) ,
  INDEX `fk_AssessmentSheetEntry_customer1` (`CustomerOid` ASC) ,
  INDEX `fk_AssessmentSheetEntry_AssessmentSheetCategory1` (`AssessmentSheetCategoryOid` ASC) ,
  INDEX `fk_AssessmentSheetEntry_AssessmentSheetValue1` (`AssessmentSheetValueOid` ASC) ,
  CONSTRAINT `fk_AssessmentSheetEntry_customer1`
    FOREIGN KEY (`CustomerOid` )
    REFERENCES `customer` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_AssessmentSheetEntry_AssessmentSheetCategory1`
    FOREIGN KEY (`AssessmentSheetCategoryOid` )
    REFERENCES `AssessmentSheetCategory` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_AssessmentSheetEntry_AssessmentSheetValue1`
    FOREIGN KEY (`AssessmentSheetValueOid` )
    REFERENCES `AssessmentSheetValue` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
COLLATE = latin1_swedish_ci;


CREATE  TABLE IF NOT EXISTS `AssessmentSheetCategory2AssessmentSheetValue` (
  `AssessmentSheetCategoryOid` BIGINT(19) NOT NULL ,
  `AssessmentSheetValueOid` BIGINT(19) NOT NULL ,
  PRIMARY KEY (`AssessmentSheetCategoryOid`, `AssessmentSheetValueOid`) ,
  INDEX `fk_AssessmentSheetCategory_has_AssessmentSheetValue_Assessmen1` (`AssessmentSheetCategoryOid` ASC) ,
  INDEX `fk_AssessmentSheetCategory_has_AssessmentSheetValue_Assessmen2` (`AssessmentSheetValueOid` ASC) ,
  CONSTRAINT `fk_AssessmentSheetCategory_has_AssessmentSheetValue_Assessmen1`
    FOREIGN KEY (`AssessmentSheetCategoryOid` )
    REFERENCES `AssessmentSheetCategory` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_AssessmentSheetCategory_has_AssessmentSheetValue_Assessmen2`
    FOREIGN KEY (`AssessmentSheetValueOid` )
    REFERENCES `AssessmentSheetValue` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
COLLATE = latin1_swedish_ci;

CREATE  TABLE IF NOT EXISTS `VarFieldDef` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `IsActive` VARCHAR(45) NULL ,
  `Notice` VARCHAR(1024) NULL ,
  `InsTs` DATETIME NULL ,
  `InsUser` VARCHAR(256) NULL ,
  `Version` BIGINT(19) NULL ,
  `UdpUser` VARCHAR(256) NULL ,
  `SystemEntryID` INT(10) NULL ,
  `GroupString` VARCHAR(512) NULL ,
  `XCoordinate` INT(10) NULL ,
  `YCoordinate` INT(10) NULL ,
  `Label` VARCHAR(512) NULL ,
  `ControlType` INT(10) NULL ,
  `PossibleItems` VARCHAR(2048) NULL ,
  `DecimalPlaces` INT(10) NULL ,
  `ObjectTid` INT(10) NULL ,
  `Height` INT(10) NULL ,
  `Width` INT(10) NULL ,
  `RowSpan` INT(10) NULL ,
  `ColumnSpan` INT(10) NULL ,
  PRIMARY KEY (`Oid`),
  KEY `ObjectTid_IDX` (`ObjectTid`) )
ENGINE = InnoDB;

CREATE  TABLE IF NOT EXISTS `VarFieldValue` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `IsActive` VARCHAR(45) NULL ,
  `Notice` VARCHAR(1024) NULL ,
  `InsTs` DATETIME NULL ,
  `InsUser` VARCHAR(256) NULL ,
  `Version` BIGINT(19) NULL ,
  `UdpUser` VARCHAR(256) NULL ,
  `SystemEntryID` INT(10) NULL ,
  `SerializedValue` VARCHAR(512) NULL ,
  `TypeName` VARCHAR(512) NULL ,
  `VarFieldDefOid` BIGINT(19) NULL ,
  `ObjectOid` BIGINT(19) NULL ,
  `ObjectTid` INT(10) NULL ,
  PRIMARY KEY (`Oid`) ,
  KEY `ObjectOid_IDX` (`ObjectOid`),
  KEY `ObjectTid_IDX` (`ObjectTid`),
  INDEX `VarFieldValue_VarFieldDef_fk` (`VarFieldDefOid` ASC) ,
  CONSTRAINT `VarFieldValue_VarFieldDef_fk`
    FOREIGN KEY (`VarFieldDefOid` )
    REFERENCES `VarFieldDef` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

CREATE  TABLE IF NOT EXISTS `Customer2AssessmentSheetCategory` (
  `CustomerOid` BIGINT(19) NOT NULL ,
  `AssessmentSheetOid` BIGINT(19) NOT NULL ,
  INDEX `Cus` (`CustomerOid` ASC) ,
  INDEX `Ass` (`AssessmentSheetOid` ASC) ,
  PRIMARY KEY (`CustomerOid`, `AssessmentSheetOid`) ,
  CONSTRAINT `Cus`
    FOREIGN KEY (`CustomerOid` )
    REFERENCES `customer` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `Ass`
    FOREIGN KEY (`AssessmentSheetOid` )
    REFERENCES `AssessmentSheetCategory` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

CREATE  TABLE IF NOT EXISTS `Task` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `IsActive` VARCHAR(45) NULL ,
  `Notice` VARCHAR(1024) NULL ,
  `InsTs` DATETIME NULL ,
  `InsUser` VARCHAR(256) NULL ,
  `Version` BIGINT(19) NULL ,
  `UdpUser` VARCHAR(256) NULL ,
  `SystemEntryID` INT(10) NULL ,
  `SupportConceptOid` BIGINT(19) NULL ,
  `Description` MEDIUMTEXT NULL ,
  `Title` MEDIUMTEXT NULL ,
  `CompletedDate` DATETIME NULL ,
  `CompletedNotice` MEDIUMTEXT NULL ,
  `DueDate` DATETIME NULL ,
  PRIMARY KEY (`Oid`) ,
  INDEX `fk_task_supportConcet` (`SupportConceptOid` ASC) ,
  CONSTRAINT `fk_task_supportConcet`
    FOREIGN KEY (`SupportConceptOid` )
    REFERENCES `supportconcept` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

CREATE  TABLE IF NOT EXISTS `Task2Employee` (
  `TaskOid` BIGINT(19) NOT NULL ,
  `EmployeeOid` BIGINT(19) NOT NULL ,
  PRIMARY KEY (`TaskOid`, `EmployeeOid`) ,
  INDEX `fk_t2em_e` (`EmployeeOid` ASC) ,
  INDEX `fk_t2em_t` (`TaskOid` ASC) ,
  CONSTRAINT `fk_t2em_e`
    FOREIGN KEY (`EmployeeOid` )
    REFERENCES `employee` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_t2em_t`
    FOREIGN KEY (`TaskOid` )
    REFERENCES `Task` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


CREATE  TABLE IF NOT EXISTS `newsitem` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `IsActive` VARCHAR(45) NULL DEFAULT NULL ,
  `Notice` VARCHAR(1024) NULL DEFAULT NULL ,
  `InsTs` DATETIME NULL DEFAULT NULL ,
  `InsUser` VARCHAR(256) NULL DEFAULT NULL ,
  `Version` BIGINT(19) NULL DEFAULT NULL ,
  `UdpUser` VARCHAR(256) NULL DEFAULT NULL ,
  `SystemEntryID` INT(10) NULL DEFAULT NULL ,
  `PublishDate` DATETIME NULL DEFAULT NULL ,
  `Title` VARCHAR(256) NULL DEFAULT NULL ,
  `Text` MEDIUMTEXT NULL DEFAULT NULL ,
  PRIMARY KEY (`Oid`) )
ENGINE = InnoDB;

CREATE  TABLE IF NOT EXISTS `BeWoFolder` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `ObjectOid` BIGINT(19) NULL DEFAULT NULL ,
  `ObjectTid` INT(10) NULL DEFAULT NULL ,
  `Name` VARCHAR(1024) NULL ,
  `Notice` VARCHAR(1024) CHARACTER SET 'latin1' NULL DEFAULT NULL ,
  `InsTs` DATETIME NULL DEFAULT NULL ,
  `InsUser` VARCHAR(256) CHARACTER SET 'latin1' NULL DEFAULT NULL ,
  `Version` BIGINT(19) NULL DEFAULT NULL ,
  `UdpUser` VARCHAR(256) CHARACTER SET 'latin1' NULL DEFAULT NULL ,
  `IsActive` TINYINT(4) NULL DEFAULT NULL ,
  `SystemEntryID` INT(10) NULL DEFAULT NULL ,
  `ParentBeWoFolderOid` BIGINT(19) NULL ,
  PRIMARY KEY (`Oid`) ,
  INDEX `folder_pFolder` (`ParentBeWoFolderOid` ASC) ,
  CONSTRAINT `folder_pFolder`
    FOREIGN KEY (`ParentBeWoFolderOid` )
    REFERENCES `BeWoFolder` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

CREATE  TABLE IF NOT EXISTS `BeWoFile` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `Type` INT(10) NULL DEFAULT NULL ,
  `Path` VARCHAR(512) CHARACTER SET 'latin1' NULL DEFAULT NULL ,
  `Notice` VARCHAR(1024) CHARACTER SET 'latin1' NULL DEFAULT NULL ,
  `InsTs` DATETIME NULL DEFAULT NULL ,
  `InsUser` VARCHAR(256) CHARACTER SET 'latin1' NULL DEFAULT NULL ,
  `Version` BIGINT(19) NULL DEFAULT NULL ,
  `UdpUser` VARCHAR(256) CHARACTER SET 'latin1' NULL DEFAULT NULL ,
  `IsActive` TINYINT(4) NULL DEFAULT NULL ,
  `SystemEntryID` INT(10) NULL DEFAULT NULL ,
  `Data` MEDIUMBLOB NULL DEFAULT NULL ,
  `BeWoFolderOid` BIGINT(19) NULL ,
  PRIMARY KEY (`Oid`) ,
  INDEX `file_folder_fk` (`BeWoFolderOid` ASC) ,
  CONSTRAINT `file_folder_fk`
    FOREIGN KEY (`BeWoFolderOid` )
    REFERENCES `BeWoFolder` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

CREATE TABLE `team2customer` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `CustomerOid` BIGINT(19) DEFAULT NULL,
  `TeamOid` BIGINT(19) NOT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `TEAM2CUSTOMERCUSTOMER_FK` (`CustomerOid`),
  KEY `TEAMTEAM2CUSTOMER_FK` (`TeamOid`),
  CONSTRAINT `FK_TEAM_TEAM2_CUSTOMER` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_TEAM_TEAM_TEAM` FOREIGN KEY (`TeamOid`) REFERENCES `team` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';


ALTER TABLE `employee`
  ADD `Text1` varchar(128) DEFAULT NULL;
  
ALTER TABLE `employee`
  ADD `Text2` varchar(128) DEFAULT NULL;
  
ALTER TABLE `employee`
  ADD `Text3` varchar(128) DEFAULT NULL;
  
ALTER TABLE `employee`
  ADD `Text4` varchar(128) DEFAULT NULL;
  
ALTER TABLE `employee`
  ADD `Text5` varchar(128) DEFAULT NULL;

  
ALTER TABLE `employee`
  ADD `Notice2` MEDIUMTEXT DEFAULT NULL;
  

CREATE  TABLE `SupportConceptApprovalPeriod` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `IsActive` VARCHAR(45) NULL ,
  `Notice` VARCHAR(1024) NULL ,
  `InsTs` DATETIME NULL ,
  `InsUser` VARCHAR(256) NULL ,
  `Version` BIGINT(19) NULL ,
  `UdpUser` VARCHAR(256) NULL ,
  `SystemEntryID` INT(10) NULL ,
  `EndDate` DATETIME NULL ,
  `Start` DATETIME NULL ,
  `MonthlyPayment` DECIMAL(18,10) NULL ,
  `IsApprovedFixedAmountShifting` TINYINT(1) NULL ,
  `ApprovedBEPerInterval` DECIMAL(18,10) NULL ,
  `ApprovedBEInterval` INT NULL ,
  `IsApprovedBEShifting` TINYINT(1) NULL ,
  `ApprovedBETotal` DECIMAL(18,10) NULL ,
  `ApprovedFixedAmount` DECIMAL(18,10) NULL ,
  `ApprovedFixedAmountInterval` INT NULL ,
  `CostBearer2SupportConceptOid` BIGINT(19) NULL ,
  PRIMARY KEY (`Oid`) ,
  INDEX `cb2sc_scap` (`CostBearer2SupportConceptOid` ASC) ,
  CONSTRAINT `cb2sc_scap`
    FOREIGN KEY (`CostBearer2SupportConceptOid` )
    REFERENCES `costbearer2supportconcept` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

CREATE  TABLE `InvoiceNumber` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `Pattern` VARCHAR(256) NULL ,
  `CurrentNumber` BIGINT NULL ,
  `IsActive` VARCHAR(45) NULL ,
  `Notice` VARCHAR(1024) NULL ,
  `InsTs` DATETIME NULL ,
  `InsUser` VARCHAR(256) NULL ,
  `Version` BIGINT(19) NULL ,
  `UdpUser` VARCHAR(256) NULL ,
  `SystemEntryID` INT(10) NULL ,
  `DoUse` bool NULL,
  PRIMARY KEY (`Oid`) )
ENGINE = InnoDB;


CREATE  TABLE `ServiceInvoice` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `IsActive` VARCHAR(45) NULL ,
  `Notice` VARCHAR(1024) NULL ,
  `InsTs` DATETIME NULL ,
  `InsUser` VARCHAR(256) NULL ,
  `Version` BIGINT(19) NULL ,
  `UdpUser` VARCHAR(256) NULL ,
  `SystemEntryID` INT(10) NULL ,
  `InvoiceBaseOid` BIGINT(19) NULL ,
  `ServiceUnitOid` bigint(19) NULL,
  `AmountAdvancePayments` decimal(18,10) DEFAULT NULL,
  `AmountEquityContribution` decimal(18,10) DEFAULT NULL,
  PRIMARY KEY (`Oid`) ,
  INDEX `serviceinvoice_invoicebase` (`InvoiceBaseOid` ASC) ,
  CONSTRAINT `serviceinvoice_invoicebase` FOREIGN KEY (`InvoiceBaseOid` ) REFERENCES `InvoiceBase` (`Oid` ) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `kf_si_crp` FOREIGN KEY (`serviceunitoid`) REFERENCES `costrateperiod`(`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
 )
ENGINE = InnoDB;

CREATE  TABLE `InvoiceItem2CostRatePeriod` (
  `InvoiceItemOid` BIGINT(19) NOT NULL ,
  `CostRatePeriodOid` BIGINT(19) NOT NULL ,
  PRIMARY KEY (`InvoiceItemOid`, `CostRatePeriodOid`) ,
  INDEX `fk_1` (`InvoiceItemOid` ASC) ,
  INDEX `fk_2` (`CostRatePeriodOid` ASC) ,
  CONSTRAINT `fk_1`
    FOREIGN KEY (`InvoiceItemOid` )
    REFERENCES `InvoiceItem` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_2`
    FOREIGN KEY (`CostRatePeriodOid` )
    REFERENCES `costrateperiod` (`Oid` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

CREATE  TABLE `ServiceInvoicePeriod` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `SupportConceptApprovalPeriodOid` BIGINT(19) NULL ,
  `Notice` VARCHAR(1024) NULL ,
  `InsTs` DATETIME NULL ,
  `InsUser` VARCHAR(256) NULL ,
  `ApprovedFixedAmount` decimal(18,10) NULL,
  `ApprovedAmountDefaultHourlyRate` decimal(18,10) NULL,
  `Claim` decimal(18,10) NULL,
  `HoursNotBillableAbsence` decimal(18,10) NULL,
  `HoursNotBillableNotApproved` decimal(18,10) NULL,
  `ApprovedBE` DECIMAL(18,10) NULL ,
  `ApprovedHours` DECIMAL(18,10) NULL ,
  `Start` DATETIME NULL ,
  `End` DATETIME NULL ,
  `ServiceUnitName` VARCHAR(256) NULL ,
  `UdpUser` VARCHAR(256) NULL ,
  `Version` BIGINT(19) NULL ,
  `IsActive` VARCHAR(45) NULL ,
  `SystemEntryID` INT(10) NULL ,
  `ServiceInvoiceOid` BIGINT(19) NULL ,
  PRIMARY KEY (`Oid`) )
ENGINE = InnoDB;

CREATE  TABLE `EmploymentType` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `Notice` VARCHAR(1024) NULL ,
  `InsTs` DATETIME NULL ,
  `InsUser` VARCHAR(256) NULL ,
  `UdpUser` VARCHAR(256) NULL ,
  `Version` BIGINT(19) NULL ,
  `IsActive` VARCHAR(45) NULL ,
  `SystemEntryID` INT(10) NULL ,
  `Name` VARCHAR(256) NULL ,
  PRIMARY KEY (`Oid`) )
ENGINE = InnoDB;

CREATE TABLE `contract` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Tid` int(10) NOT NULL,
  `EmployeeOid` bigint(19) DEFAULT NULL,
  `EmploymentTypeOid` bigint(19) DEFAULT NULL,
  `Notice` MEDIUMTEXT DEFAULT NULL,
  `HourlyRate` decimal(18,10) DEFAULT NULL,
  `EntryDate` datetime DEFAULT NULL,
  `ContractEndDate` datetime DEFAULT NULL,
  `CancellationPeriod` int(10) DEFAULT NULL,
  `ProbationPeriod` int(10) DEFAULT NULL,
  `WeeklyFls` decimal(18,10) DEFAULT NULL,
  `WeeklyTotalhours` decimal(18,10) DEFAULT NULL,
  `LeaveDays` decimal(18,10) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `CONTRACTEMPLOYEE_FK` (`EmployeeOid`),
  KEY `CONTRACT_EMPLOYMENTTYPE_FK` (`EmploymentTypeOid`),
  CONSTRAINT `FK_CONTRACT_EMPLOYEE` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_CONTRACT_EMPLOYMENTTYPE` FOREIGN KEY (`EmploymentTypeOid`) REFERENCES `EmploymentType` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;





CREATE  TABLE `AppointmentCategory` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `IsActive` TINYINT NULL ,
  `Notice` VARCHAR(1024) NULL ,
  `InsTs` DATETIME NULL ,
  `InsUser` VARCHAR(256) NULL ,
  `Version` BIGINT(19) NULL ,
  `UdpUser` VARCHAR(256) NULL ,
  `SystemEntryID` INT(10) NULL ,
  `Color` VARCHAR(16) NULL ,
  `DisplayName` VARCHAR(128) NULL ,
  PRIMARY KEY (`Oid`))
ENGINE = InnoDB;

CREATE  TABLE `Appointment` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT ,
  `Tid` INT(10) NOT NULL ,
  `IsActive` TINYINT NULL ,
  `Notice` MEDIUMTEXT NULL ,
  `InsTs` DATETIME NULL ,
  `InsUser` VARCHAR(256) NULL ,
  `Version` BIGINT(19) NULL ,
  `UdpUser` VARCHAR(256) NULL ,
  `SystemEntryID` INT(10) NULL ,
  `Type` INT NULL ,
  `StartDate` DATETIME NULL ,
  `EndDate` DATETIME NULL ,
  `AllDay` BIT NULL ,
  `Subject` VARCHAR(256) NULL ,
  `Location` VARCHAR(256) NULL ,
  `Status` INT NULL ,
  `RecurrenceInfo` MEDIUMTEXT NULL ,
  `ReminderInfo` MEDIUMTEXT NULL ,
  `AppointmentCategoryOid` BIGINT(19) NULL ,
  `CustomerOid` BIGINT(19) NULL ,
  `EmployeeOid` BIGINT(19) NULL ,
  PRIMARY KEY (`Oid`) ,
  INDEX `ix_app_cat` (`AppointmentCategoryOid` ASC) ,
  INDEX `ix_app_cust` (`CustomerOid` ASC) ,
  INDEX `ix_app_emp` (`EmployeeOid` ASC) ,
  CONSTRAINT `fk_app_cat` FOREIGN KEY (`AppointmentCategoryOid` ) REFERENCES `AppointmentCategory` (`Oid` ),
  CONSTRAINT `fk_app_cust` FOREIGN KEY (`CustomerOid` ) REFERENCES `Customer` (`Oid`),
  CONSTRAINT `fk_app_emp` FOREIGN KEY (`EmployeeOid` ) REFERENCES `Employee` (`Oid`))
ENGINE = InnoDB;

CREATE TABLE `customer2organisation` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `CustomerOid` BIGINT(19) DEFAULT NULL,
  `OrganisationOid` BIGINT(19) NOT NULL,
  `Tid` INTEGER(10) NOT NULL,
  `Type` INTEGER(10) DEFAULT NULL,
  `Notice` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Info1` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Info2` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Info3` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Info4` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Info5` VARCHAR(1024) COLLATE latin1_swedish_ci DEFAULT NULL,
  `InsTs` DATETIME DEFAULT NULL,
  `InsUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `Version` BIGINT(19) DEFAULT NULL,
  `UdpUser` VARCHAR(256) COLLATE latin1_swedish_ci DEFAULT NULL,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `CUSTOMERCUSTOMER2ORGANISATION_FK` (`CustomerOid`),
  KEY `PERSONCUSTOMER2ORGANISATION_FK` (`OrganisationOid`),
  CONSTRAINT `FK_CUSTOMER2ORG_CUSTOMER` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_CUSTOMER2ORG_ORGANISATION` FOREIGN KEY (`OrganisationOid`) REFERENCES `organisation` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';


INSERT INTO `invoicenumber` (`Oid`, `Tid`, `Pattern`, `CurrentNumber`, `IsActive`, `Notice`, `InsTs`, `InsUser`, `Version`, `UdpUser`, `SystemEntryID`) VALUES (1, 63, '{n}', 1, '1', NULL, '2011-01-08 20:29:30', 'System', 1, 'System', 6);
COMMIT;



INSERT INTO `usergroup` (`Oid`, `ParentGroupOid`, `Tid`, `Name`, `Description`, `Notice`, `Version`, `InsTs`, `InsUser`, `UdpUser`, `IsActive`, `SystemEntryID`) VALUES 
  (1,NULL,0,'Administratoren',NULL,NULL,1,'2009-01-13 17:20:18','Max Mustermann','Max Mustermann',1,NULL),
  (2,NULL,0,'Mitarbeiter',NULL,NULL,1,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,NULL);
COMMIT;


INSERT INTO `rightrelation` (`Oid`, `ApplicationUserOid`, `UserGroupOid`, `Tid`, `RightType`, `Notice`, `InsTs`, `InsUser`, `UdpUser`, `Version`, `IsActive`, `SystemEntryID`) VALUES 
  (1,NULL,1,0,1,NULL,'2009-01-13 17:20:18','Max Mustermann','Max Mustermann',1,1,NULL),
  (2,NULL,1,0,2,NULL,'2009-01-13 17:20:18','Max Mustermann','Max Mustermann',1,1,NULL),
  (3,NULL,1,0,4,NULL,'2009-01-13 17:20:18','Max Mustermann','Max Mustermann',1,1,NULL),
  (4,NULL,1,0,8,NULL,'2009-01-13 17:20:18','Max Mustermann','Max Mustermann',1,1,NULL),
  (5,NULL,2,0,1048576,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL),
  (6,NULL,2,0,2097152,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL),
  (7,NULL,2,0,33554432,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL),
  (8,NULL,2,0,16777216,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL),
  (9,NULL,2,0,536870912,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL),
  (10,NULL,2,0,268435456,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL),
  (11,NULL,2,0,8589934592,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL),
  (12,NULL,2,0,4294967296,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL),
  (13,NULL,2,0,8192,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL),
  (14,NULL,2,0,4096,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL),
  (15,NULL,2,0,16384,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL),
  (16,NULL,2,0,32768,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL),
  (17,NULL,2,0,32,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL),
  (18,NULL,2,0,64,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL),
  (19,NULL,2,0,16,NULL,'2009-01-20 11:41:35','Max Mustermann','Max Mustermann',1,1,NULL);
COMMIT;



INSERT INTO `address` (`Oid`, `Tid`, `Street`, `PostalCode`, `Town`, `State`, `Country`, `Notice`, `InsTs`, `InsUser`, `Version`, `UdpUser`, `IsActive`, `SystemEntryID`) VALUES 
  (1,5,'Kennedy-Ufer 2','50663 ','Köln',NULL,NULL,NULL,'2008-11-10 11:18:42','Max Mustermann',1,'Max Mustermann',1,NULL);
COMMIT;

INSERT INTO `costbearer` (`Oid`, `Tid`, `HourlyRate`, `RateFactor`, `Notice`, `InsTs`, `InsUser`, `UdpUser`, `Version`, `IsActive`, `MinutesIntervall`, `ReferenceNumber`, `SystemEntryID`) VALUES 
  (1,22,49.9000000000,20.0000000000,NULL,'2008-10-05 19:12:11','Max Mustermann','Max Mustermann',1,1,10,NULL,0);
COMMIT;

INSERT INTO `organisation` (`Oid`, `BankAccountOid`, `AddressOid`, `CostBearerOid`, `Tid`, `Notice`, `InsTs`, `InsUser`, `Version`, `UdpUser`, `Name`, `IsActive`, `SystemEntryID`) VALUES 
  (1,NULL,1,1,11,NULL,'2008-10-05 19:12:11','Max Mustermann',2,'Max Mustermann','LVR',1,NULL);
COMMIT;

INSERT INTO `costrateperiod` (`Oid`, `ObjectOid`, `ObjectTid`, `CostRateType`, `CostRateValue`, `StartDate`, `EndDate`, `Notice`, `InsTs`, `InsUser`, `Version`, `UdpUser`, `IsActive`, `SystemEntryID`, `UnitName`) VALUES 
  (1,1,22,0,50.4000000000,NULL,NULL,NULL,'2009-09-30 00:00:00','BS',1,'BS',1,NULL, NULL),
  (2,1,22,1,10.0000000000,NULL,NULL,NULL,'2009-09-30 00:00:00','BS',1,'BS',1,NULL, NULL),
  (3,1,22,2,20.0000000000,NULL,NULL,NULL,'2009-09-30 00:00:00','BS',1,'BS',1,NULL, NULL),
  (4,1,22,3,60.0000000000,NULL,NULL,NULL,'2009-09-30 00:00:00','BS',1,'BS',1,NULL, 'FLS');
COMMIT;


INSERT INTO `valuelistentry` (`Oid`, `Tid`, `Type`, `Value`, `Abbreviation`, `IsActive`, `SystemEntryID`, `Notice`, `InsTs`, `InsUser`, `Version`, `UdpUser`, `ParentOid`) VALUES 
  (1,4,3,'Hauptbetreuung',NULL,1,3,NULL,'2008-10-05 19:13:22','Max Mustermann',1,'Max Mustermann',NULL),
  (2,4,7,'Gesetzlicher Vertreter',NULL,1,2,NULL,'2008-10-22 11:31:08','Max Mustermann',1,'Max Mustermann',NULL),
  (3,4,7,'Vertrauensperson',NULL,1,1,NULL,'2008-10-22 11:20:17','Max Mustermann',1,'Max Mustermann',NULL);
COMMIT;