
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(256) DEFAULT NULL,
  `AddressLine2` VARCHAR(256) 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 DEFAULT NULL,
  `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(256) 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,
  `IsMigrant` TINYINT(4) NULL DEFAULT NULL,
  `NationalitaetValueListEntryOid` BIGINT(19) NULL DEFAULT NULL,
  `AufenthaltsStatusValueListEntryOid` BIGINT(19) NULL 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,
  `AssistanceBegin` DATETIME 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,
  `Environment` VARCHAR(2048) DEFAULT NULL,
  `OrganisationOid` BIGINT(19) NULL DEFAULT NULL,
  `AnsprechpartnerOid` BIGINT(19) NULL DEFAULT NULL,
  `DistanceInMeter` int(10) DEFAULT NULL,
  `Auszahlungsintervall` TINYINT(10) DEFAULT NULL,
  `AusstVersAmt` VARCHAR(1024) DEFAULT NULL,
  `AusweisGueltigVon` DATETIME DEFAULT NULL,
  `AusweisGueltigBis` DATETIME DEFAULT NULL,
  `AusweisUnbefristetGueltig` TINYINT(1) DEFAULT NULL,
  `BeiblattGueltigBis` DATETIME DEFAULT NULL,
  `GradDerBehinderung` VARCHAR(1024) DEFAULT NULL,
  `Pflegegrad` INTEGER(10) DEFAULT NULL,
  `CustomerImage` longblob DEFAULT NULL,
  `CustomerAlias` VARCHAR(256) DEFAULT NULL,
  `VertretungGewuenscht` TINYINT(4) NULL DEFAULT 1 COMMENT '',
  `AbWelchemKrankheitsTag` INT(10) NULL DEFAULT 0,
  `VertretungDringendErforderlich` TINYINT(4) NULL DEFAULT 1,
  `Pflege` tinyint(4) DEFAULT NULL,
  `Toilettengang` tinyint(4) DEFAULT NULL,
  `Aggressiv` tinyint(4) DEFAULT NULL,
  `Schutzstufe` varchar(1024) DEFAULT NULL,
  `Hygienebelehrung` tinyint(4) 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,
  CONSTRAINT `FK_ORGANISATION2` FOREIGN KEY (`OrganisationOid`) REFERENCES `organisation` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_ANSPRECHPARTNER` FOREIGN KEY (`AnsprechpartnerOid` ) 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,
  `KrankheitsMeldung` DATETIME NULL 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,
  `CreationDate` DATETIME DEFAULT NULL,
  `PasswordHash` VARCHAR(1024) NULL 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,
  `Text1` varchar(128) DEFAULT NULL,
  `Text2` varchar(128) DEFAULT NULL,
  `Text3` varchar(128) DEFAULT NULL,
  `Text4` varchar(128) DEFAULT NULL,
  `Text5` varchar(128) DEFAULT NULL,
  `Notice2` MEDIUMTEXT DEFAULT NULL,
  `EmployeeColor` VARCHAR(9),
  `Pflege` tinyint(4) DEFAULT NULL,
  `Toilettengang` tinyint(4) DEFAULT NULL,
  `Aggressiv` tinyint(4) DEFAULT NULL,
  `Schutzstufe` varchar(1024) DEFAULT NULL,
  `Hygienebelehrung` 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` 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,
  `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,
  `AuswahlBezeichnung` VARCHAR(512) 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,
  `Name2` 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,
  `FunctionValueListEntryOid` BIGINT(19) NULL 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,
  `ValidityDate` DATETIME DEFAULT NULL,
  `ImportNotice` VARCHAR(256) NULL 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,
  `RolleInOrganisationValueListOid` BIGINT(19) NULL 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,
  `IstFamilie` TINYINT(4) NULL DEFAULT NULL,
  `OrganisationOid` BIGINT(19) NULL 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,
  `Chatpartner` TINYINT(4) NULL DEFAULT 0,
  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,
  `FileName` VARCHAR(256) NULL DEFAULT NULL,
  `ExportTitle` VARCHAR(256) NULL 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,
  `BillableAmount` DECIMAL(18,10) DEFAULT NULL,
  `AccountingInterval`  INTEGER(10) DEFAULT NULL,
  `Position`  INTEGER(10) DEFAULT NULL,
  `ServiceCategoryType`  INTEGER(10) DEFAULT NULL,
  `ScopeType`  INTEGER(10) DEFAULT NULL,
  `IsDefault` tinyint(1) DEFAULT NULL,
  `NurOhneHilfeplan` TINYINT(4) 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,
  `BillableAmount` DECIMAL(18,10) DEFAULT NULL,
  `AccountingInterval`  INTEGER(10) DEFAULT NULL,
  `Position`  INTEGER(10) DEFAULT NULL,
  `Unit`  INTEGER(10) DEFAULT NULL,
  `ScopeType`  INTEGER(10) DEFAULT NULL,
  `IsDefault` tinyint(1) DEFAULT NULL,
  `DoNotCheckOverlapping` tinyint(1) 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,
  `Notice2` MEDIUMTEXT DEFAULT NULL,
  `Notice3` MEDIUMTEXT DEFAULT NULL,
  `Notice4` MEDIUMTEXT DEFAULT NULL,
  `Notice5` MEDIUMTEXT 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,
  `ServiceRecordType` INTEGER(10) DEFAULT NULL,
  `DistanceInMeter` int(10) DEFAULT NULL,
  `Relevance` int(10) DEFAULT NULL,
  `IsCreatedInMobileClient` TINYINT(1) DEFAULT 0,
  `SignatureOID` BIGINT(19) DEFAULT NULL,
  `WohnheimbuchungsOid` BIGINT(19) DEFAULT NULL,
  `Notice2` MEDIUMTEXT DEFAULT NULL,
  `Notice3` MEDIUMTEXT DEFAULT NULL,
  `Notice4` MEDIUMTEXT DEFAULT NULL,
  `Notice5` MEDIUMTEXT DEFAULT NULL,
  `DurationInStunden` INT(10) NULL DEFAULT NULL,
  `ServiceRecordFormat` INT(10) NULL DEFAULT NULL,
  `RTFNotice1` MEDIUMTEXT NULL DEFAULT NULL,
  `RTFNotice2` MEDIUMTEXT NULL DEFAULT NULL,
  `RTFNotice3` MEDIUMTEXT NULL DEFAULT NULL,
  `RTFNotice4` MEDIUMTEXT NULL DEFAULT NULL,
  `RTFNotice5` MEDIUMTEXT NULL 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`),
  KEY `IDX_StartDate` (`StartDate`),
  KEY `IDX_EndDate` (`EndDate`),
  CONSTRAINT `FK_SERVICERECORD_WOHNHEIMBUCHUNG` FOREIGN KEY(`WohnheimbuchungsOid`) REFERENCES `wohnheimbuchung` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  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` DATE DEFAULT NULL,
  `EndDate` DATE 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` int(10) DEFAULT NULL,
  `CreationDate` datetime DEFAULT NULL,
  `SignDate` datetime DEFAULT NULL,
  `Notice` mediumtext,
  `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,
  `EmployeeOid` bigint(19) DEFAULT NULL,
  `CustomerOid` bigint(19) DEFAULT NULL,
  `StartDate` datetime DEFAULT NULL,
  `EndDate` datetime DEFAULT NULL,
  `PrintedDate` datetime DEFAULT NULL,
  `PrintedByEmployeeOid` bigint(19) DEFAULT NULL,
  `SignedByEmployeeOid` bigint(19) DEFAULT NULL,
  `UpdTs` datetime DEFAULT NULL,
  `Status` varchar(1024) 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,
  `RssFeedUrl` VARCHAR(2048) 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,
	`IsSchedulerAllowed` tinyint(1) DEFAULT NULL,
	`IsMedicationAllowed` tinyint(1) DEFAULT NULL,
	`ApiKey` VARCHAR(256) NULL 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(256) 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,
  `InvoiceId` varchar(64) DEFAULT NULL,
  `InvoiceTypeText` VARCHAR(256) DEFAULT NULL,
  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)
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(256) 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),
	`AccountingInterval`  INTEGER(10) DEFAULT NULL,
	`ReceivedAmount` decimal(18,10)  DEFAULT NULL,
	`MaxApprovedAmount` decimal(18,10)  DEFAULT NULL,
	`MaxApprovedUnitCount` decimal(18,10)  DEFAULT NULL,
	`ApprovedPerUnit` decimal(18,10)  DEFAULT NULL,
	`ApprovalUnit` INTEGER(10) DEFAULT NULL,
  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_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 ,
  `ErrorNotice` VARCHAR(2000) 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,
  `ScopeType`  INTEGER(10) 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 ,
  `TeamOid` bigint(19) NULL,
  PRIMARY KEY (`Oid`),
  KEY `TEAM_NEWSITEM_FK` (`TeamOid`),
  CONSTRAINT `FK_TEAM_NEWSITEM` FOREIGN KEY (`TeamOid`) REFERENCES `Team` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION)
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';


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 ,
  `Percentage` DECIMAL(18,10) DEFAULT NULL,
  `SupportConceptOid` BIGINT(19) DEFAULT NULL,
  `ServiceCategoryOid` BIGINT(19) DEFAULT NULL,
  `ContactCountPerInterval` decimal(18,10) DEFAULT NULL,
  `ContactCountInterval` int(11) DEFAULT NULL,
  PRIMARY KEY (`Oid`) ,
  KEY `SUPPORTCONCEPTAPPROVAL_KEY` (`SupportConceptOid`),
  KEY `SERVICECATEGORY_APPROVAL_KEY` (`ServiceCategoryOid`),
  INDEX `cb2sc_scap` (`CostBearer2SupportConceptOid` ASC) ,
  CONSTRAINT `FK_APPROVAL_SUPPORTCONCEPT` FOREIGN KEY (`SupportConceptOid`) REFERENCES `supportconcept` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_APPROVAL_SERVICECATEGORY` FOREIGN KEY (`ServiceCategoryOid`) REFERENCES `servicecategory` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  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 ,
  `AccountingInterval`  INTEGER(10) DEFAULT NULL,
  `CustomerOid` BIGINT(19) NULL DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  CONSTRAINT `FK_SI2CUSTOMER` FOREIGN KEY (`CustomerOid` ) REFERENCES `customer` (`Oid` )  ON DELETE NO ACTION ON UPDATE NO ACTION  )
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,
  `WeeklyDays` int(10) DEFAULT NULL,
  `MonthlyTotalHours` DECIMAL(18,10) NULL DEFAULT NULL,
  `MonthlyFLS` DECIMAL(18,10) NULL DEFAULT NULL,
  `HourlyRateCostRateValueOid` bigint(19) NULL DEFAULT NULL,
  `[REDACTED]` decimal(18,10) NULL DEFAULT NULL,
  `ContractTypeValueListEntryOid` bigint(10) NULL DEFAULT NULL,
  `QualifikationsBedarfValueListEntryOid` bigint(10) NULL 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,
  `PersonOid` BIGINT(19) NULL 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';


CREATE TABLE `serviceaccounting` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `ServiceDescriptionOid` BIGINT(19) NOT NULL,
  `CustomerOid` BIGINT(19) DEFAULT NULL,
  `SupportConceptOid` BIGINT(19) DEFAULT NULL,
  `SupportConceptApprovalPeriodOid` BIGINT(19) DEFAULT NULL,
  `OrganisationOid` 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,
  `IsActive` TINYINT(4) DEFAULT NULL,
  `SystemEntryID` INTEGER(10) DEFAULT NULL,
  `BillableAmount` DECIMAL(18,10) DEFAULT NULL,
  `AccountingInterval`  INTEGER(10) DEFAULT NULL,
  `IsDefault` TINYINT(4) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `SERVICEDESCRIPTION_KEY` (`ServiceDescriptionOid`),
  KEY `SERVICEDESCRIPTION2CUSTOMER_KEY` (`CustomerOid`),
  KEY `SERVICEDESCRIPTION2ORGANISATION_FK` (`OrganisationOid`),
  KEY `SERVICEDESCRIPTION2SUPPORTCONCEPT_FK` (`SupportConceptOid`),
  KEY `SERVICEDESCRIPTION2APPROVALPERIOD_FK` (`SupportConceptApprovalPeriodOid`),
  CONSTRAINT `FK_SERVICEACCOUNTING_DESCRIPTION` FOREIGN KEY (`ServiceDescriptionOid`) REFERENCES `servicedescription` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_SERVICEACCOUNTING_CUSTOMER` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_SERVICEACCOUNTING_SUPPORTCONCEPT` FOREIGN KEY (`SupportConceptOid`) REFERENCES `supportconcept` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_SERVICEACCOUNTING_APPROVALPERIOD` FOREIGN KEY (`SupportConceptApprovalPeriodOid`) REFERENCES `supportconceptapprovalperiod` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_SERVICEACCOUNTING_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';

CREATE TABLE `groupofpeople` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `grouptype` INTEGER(10) NOT NULL,
  `Name` VARCHAR(256) 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,
  `CreatedByEmployeeOid` BIGINT(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
)ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';



CREATE TABLE `groupmember` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `GroupOfPeopleOid` BIGINT(19) DEFAULT NULL,
  `CustomerOid` BIGINT(19) DEFAULT NULL,
  `SupportConceptOid` BIGINT(19) DEFAULT NULL,
  `EmployeeOid` BIGINT(19) DEFAULT NULL,
  `CostBearer2SupportConceptOid` BIGINT(19) DEFAULT NULL,
  `Position` INTEGER(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `GROUPOFPEOPLE_KEY` (`GroupOfPeopleOid`),
  KEY `GROUP2CUSTOMER_KEY` (`CustomerOid`),
  KEY `GROUP2SUPPORTCONCEPT_FK` (`SupportConceptOid`),
  KEY `GROUP2COSTBEARER2SUPPORTCONCEPT_FK` (`CostBearer2SupportConceptOid`),
  KEY `GROUP2EMPLOYEE_FK` (`EmployeeOid`),
  CONSTRAINT `FK_GROUPOFPEOPLE` FOREIGN KEY (`GroupOfPeopleOid`) REFERENCES `groupofpeople` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_GROUP_CUSTOMER` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_GROUP_SUPPORTCONCEPT` FOREIGN KEY (`SupportConceptOid`) REFERENCES `supportconcept` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_GROUP_COSTBEARER2SUPPORTCONCEPT` FOREIGN KEY (`CostBearer2SupportConceptOid`) REFERENCES `costbearer2supportconcept` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_GROUP_ORGANISATION` 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 `familydata` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Tid` int(10) NOT NULL,
  `Notice` varchar(1024) 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,
  `CustomerOid` bigint(19) DEFAULT NULL,
  `Kindesmutter` varchar(1024) DEFAULT NULL,
  `Kindesvater` varchar(1024) DEFAULT NULL,
  `Geschwister` varchar(1024) DEFAULT NULL,
  `Vormund` varchar(1024) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `FK_FAMILYDATA_CUSTOMER` (`CustomerOid`),
  CONSTRAINT `FK_FAMILYDATA_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 `servicerecordhistory` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Tid` int(10) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `TimeStamp` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `ChangeType` tinyint(4) DEFAULT NULL,
  `ServiceRecordOid` bigint(19) NOT NULL,
  `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,
  `StartDate` datetime DEFAULT NULL,
  `EndDate` datetime DEFAULT NULL,
  `IP` varchar(128) DEFAULT NULL,
  `RoundedDuration` decimal(18,10) DEFAULT NULL,
  `Notice` mediumtext,
  `ServiceRecordInsTs` datetime DEFAULT NULL,
  `ServiceRecordInsUser` varchar(256) DEFAULT NULL,
  `ServiceRecordVersion` bigint(19) DEFAULT NULL,
  `ServiceRecordUdpUser` varchar(256) DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `GroupPersonCount` int(10) DEFAULT NULL,
  `GroupEmployeeCount` int(10) DEFAULT NULL,
  `GroupRoundedDuration` decimal(18,10) DEFAULT NULL,
  `GroupOid` bigint(19) DEFAULT NULL,
  `ServiceRecordType` int(10) DEFAULT NULL,
  `DistanceInMeter` int(10) DEFAULT NULL,
  `Relevance` int(10) DEFAULT NULL,
  `IsCreatedInMobileClient` TINYINT(1) DEFAULT 0,
  `Notice2` MEDIUMTEXT DEFAULT NULL,
  `Notice3` MEDIUMTEXT DEFAULT NULL,
  `Notice4` MEDIUMTEXT DEFAULT NULL,
  `Notice5` MEDIUMTEXT DEFAULT NULL,
  PRIMARY KEY (`Oid`)
) ENGINE=InnoDB
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';



CREATE TABLE `customerhistory` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Tid` int(10) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `ChangeType` tinyint(4) DEFAULT NULL,
  `CustomerOid` bigint(19) NOT NULL,
  `PersonOid` bigint(19) NOT NULL,
  `ReferenceNumber` varchar(128) DEFAULT NULL,
  `EquityContribution` decimal(18,10) DEFAULT NULL,
  `Diagnosis` mediumtext,
  `ICD10Diagnosis` mediumtext,
  `Childs` varchar(256) DEFAULT NULL,
  `Notice` mediumtext,
  `CustomerInsTs` datetime DEFAULT NULL,
  `CustomerInsUser` varchar(256) DEFAULT NULL,
  `CustomerVersion` bigint(19) DEFAULT NULL,
  `CustomerUdpUser` varchar(256) DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `AssistanceBegin` DATETIME DEFAULT NULL,
  `TerminationValueListEntryOid` bigint(19) DEFAULT NULL,
  `TerminationDate` datetime DEFAULT NULL,
  `DebitorNumber` varchar(128) DEFAULT NULL,
  `IsAdvisedOrAttended` tinyint(4) DEFAULT NULL,
  `Medication` varchar(1024) DEFAULT NULL,
  `CostCenter` varchar(128) DEFAULT NULL,
  `Environment` varchar(2048) DEFAULT NULL,
  `OrganisationOid` BIGINT(19) DEFAULT NULL,
  `AnsprechpartnerOid` BIGINT(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
) ENGINE=InnoDB 
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';


CREATE TABLE `customer2organisationhistory` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Customer2OrganisationOid` bigint(19) NOT NULL,
  `CustomerOid` bigint(19) DEFAULT NULL,
  `OrganisationOid` bigint(19) NOT NULL,
  `Tid` int(10) NOT NULL,
  `Type` int(10) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `Info1` varchar(1024) DEFAULT NULL,
  `Info2` varchar(1024) DEFAULT NULL,
  `Info3` varchar(1024) DEFAULT NULL,
  `Info4` varchar(1024) DEFAULT NULL,
  `Info5` varchar(1024) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `Customer2OrganisationInsTs` datetime DEFAULT NULL,
  `Customer2OrganisationInsUser` varchar(256) DEFAULT NULL,
  `Customer2OrganisationVersion` bigint(19) DEFAULT NULL,
  `Customer2OrganisationUdpUser` varchar(256) DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `ChangeType` tinyint(4) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
) ENGINE=InnoDB 
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';



CREATE TABLE `customer2personhistory` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `CustomerOid` bigint(19) DEFAULT NULL,
  `customer2personOid` bigint(19) NOT NULL,
  `PersonOid` bigint(19) NOT NULL,
  `Tid` int(10) NOT NULL,
  `Type` int(10) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `ChangeType` tinyint(4) DEFAULT NULL,
  `customer2personInsTs` datetime DEFAULT NULL,
  `customer2personInsUser` varchar(256) DEFAULT NULL,
  `customer2personVersion` bigint(19) DEFAULT NULL,
  `customer2personUdpUser` varchar(256) DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
) ENGINE=InnoDB 
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';



CREATE TABLE `employee2customerhistory` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `CustomerOid` bigint(19) DEFAULT NULL,
  `EmployeeOid` bigint(19) NOT NULL,
  `Employee2CustomerOid` bigint(19) NOT NULL,
  `Tid` int(10) NOT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `ChangeType` tinyint(4) DEFAULT NULL,
  `Employee2CustomerInsTs` datetime DEFAULT NULL,
  `Employee2CustomerInsUser` varchar(256) DEFAULT NULL,
  `Employee2CustomerVersion` bigint(19) DEFAULT NULL,
  `Employee2CustomerUdpUser` varchar(256) DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
) ENGINE=InnoDB 
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';



	
CREATE TABLE `temporarytoken` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Tid` int(10) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `EmployeeOid` bigint(19) DEFAULT NULL,
  `ExpirationDate` datetime DEFAULT NULL,
  `RequestedLink` varchar(4096) DEFAULT NULL,
  `EncodedToken` varchar(4096) DEFAULT NULL,
  `IsPermaLink` bit(1) DEFAULT NULL,
  `CreatorIP` varchar(32) DEFAULT NULL,
  `ConsumerIP` varchar(32) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `FK_TEMPORARYTOKEN_EMPLOYEE` (`EmployeeOid`),
  CONSTRAINT `FK_TEMPORARYTOKEN_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 `additionalservice` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `Tid` int(10) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `Name` varchar(256) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
) ENGINE=InnoDB 
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';


CREATE TABLE `additionalserviceregion` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `Tid` int(10) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `AdditionalServiceOid` bigint(19) DEFAULT NULL,
  `Name` varchar(256) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `FK_ADDITIONALSERVICEREGION_ADDITIONALSERVICE` (`AdditionalServiceOid`),
  CONSTRAINT `FK_ADDITIONALSERVICEREGION_ADDITIONALSERVICE` FOREIGN KEY (`AdditionalServiceOid`) REFERENCES `additionalservice` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB 
AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE IF NOT EXISTS `additionalservicegroupofpeople` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Name` varchar(256) DEFAULT NULL,
  `Appointment` varchar(50) DEFAULT NULL,
  `Tid` int(10) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE IF NOT EXISTS `additionalservicegroupmember` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `AdditionalServiceGroupOfPeopleOid` bigint(19) DEFAULT NULL,
  `CustomerOid` bigint(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `FK_ADDITIONALSERIVCEGROUPMEMBER_ADDITIONALSERVICEGROUPOFPEOPLE` (`AdditionalServiceGroupOfPeopleOid`),
  KEY `FK_ADDITIONALSERIVCEGROUPMEMBER_CUSTOMER` (`CustomerOid`),
  CONSTRAINT `FK_ADDITIONALSERIVCEGROUPMEMBER_ADDITIONALSERVICEGROUPOFPEOPLE` FOREIGN KEY (`AdditionalServiceGroupOfPeopleOid`) REFERENCES `additionalservicegroupofpeople` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_ADDITIONALSERIVCEGROUPMEMBER_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 IF NOT EXISTS `additionalservice2groupofpeople` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Tid` int(10) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `AdditionalServiceGroupOfPeopleOid` bigint(19) DEFAULT NULL,
  `AdditionalServiceOid` bigint(19) DEFAULT NULL,
  `RoundedDuration` decimal(18,10) DEFAULT NULL,
  `StartDate` datetime DEFAULT NULL,
  `EndDate` datetime DEFAULT NULL,
  `Datum` datetime DEFAULT NULL,
  `AdditionalServiceRegionOid` bigint(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `FK_ADDITIONALSERIVCE2GROUPOFPEOPLE_ADDITIONALSERVICE` (`AdditionalServiceOid`),
  KEY `FK_ADDITIONALSERIVCE2GROUPOFPEOPLE_ADDSERVICEGROUPOFPEOPLE` (`AdditionalServiceGroupOfPeopleOid`),
  KEY `FK_ADDITIONALSERVICE2GROUPOFPEOPLE_ADDSERVICEREGION` (`AdditionalServiceRegionOid`),
  CONSTRAINT `FK_ADDITIONALSERIVCE2GROUPOFPEOPLE_ADDITIONALSERVICE` FOREIGN KEY (`AdditionalServiceOid`) REFERENCES `additionalservice` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_ADDITIONALSERIVCE2GROUPOFPEOPLE_ADDSERVICEGROUPOFPEOPLE` FOREIGN KEY (`AdditionalServiceGroupOfPeopleOid`) REFERENCES `additionalservicegroupofpeople` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_ADDITIONALSERVICE2GROUPOFPEOPLE_ADDSERVICEREGION` FOREIGN KEY (`AdditionalServiceRegionOid`) REFERENCES `additionalserviceregion` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE IF NOT EXISTS `additionalservicebooking` (
	`Oid` BIGINT(19)  NOT NULL AUTO_INCREMENT,
	`Tid` INT(10) DEFAULT NULL,
	`Notice` VARCHAR(1024) DEFAULT NULL,
    `IsActive` tinyint(4) DEFAULT NULL,
    `InsTs` datetime DEFAULT NULL,
    `InsUser` VARCHAR(256) DEFAULT NULL,
    `UdpUser` VARCHAR(256) DEFAULT NULL,
    `SystemEntryID` INT(10) DEFAULT NULL,
    `Version` bigint(19) DEFAULT NULL,
	`AdditionalServiceRegionOid` BIGINT(19) DEFAULT NULL,
	`RoundedDuration` DECIMAL(18,10) DEFAULT NULL,
    `StartDate` DATETIME DEFAULT NULL,
    `EndDate` DATETIME DEFAULT NULL,
    `Datum` DATETIME DEFAULT NULL,
	PRIMARY KEY (`Oid`),
	KEY `FK_ADDITIONALSERVICEBOOKING_ADDSERVICEREGION` (`AdditionalServiceRegionOid`),
	CONSTRAINT `FK_ADDITIONALSERVICEBOOKING_ADDSERVICEREGION` 
		FOREIGN KEY (`AdditionalServiceRegionOid`) 
		REFERENCES `AdditionalServiceRegion` (`Oid`) 
		ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE IF NOT EXISTS `customer2addservicebooking` (
	`Oid` BIGINT(19)  NOT NULL AUTO_INCREMENT,
	`AdditionalServiceBookingOid`  BIGINT(19)  DEFAULT NULL,
	`CustomerOid`  BIGINT(19)  DEFAULT NULL,
	`Participated` TINYINT(1) DEFAULT 1,
	PRIMARY KEY (`Oid`),
	KEY `FK_CUSTOMER2ADDSERVICEBOOKING_ADDSERVICEBOOKING` (`AdditionalServiceBookingOid`),
	CONSTRAINT `FK_CUSTOMER2ADDSERVICEBOOKING_ADDSERVICEBOOKING`
		FOREIGN KEY (`AdditionalServiceBookingOid`)
		REFERENCES `AdditionalServiceBooking` (`Oid`)
		ON DELETE NO ACTION ON UPDATE NO ACTION,
	KEY `FK_CUSTOMER2ADDSERVICEBOOKING_CUSTOMER` (`CustomerOid`),
	CONSTRAINT `FK_CUSTOMER2ADDSERVICEBOOKING_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 IF NOT EXISTS `employee2addservicebooking` (
	`Oid` BIGINT(19)  NOT NULL AUTO_INCREMENT,
	`AdditionalServiceBookingOid`  BIGINT(19)  DEFAULT NULL,
	`EmployeeOid`  BIGINT(19)  DEFAULT NULL,
	PRIMARY KEY (`Oid`),
	KEY `FK_EMPLOYEE2ADDSERVICEBOOKING_ADDSERVICEBOOKING` (`AdditionalServiceBookingOid`),
	CONSTRAINT `FK_EMPLOYEE2ADDSERVICEBOOKING_ADDSERVICEBOOKING`
		FOREIGN KEY (`AdditionalServiceBookingOid`)
		REFERENCES `AdditionalServiceBooking` (`Oid`)
		ON DELETE NO ACTION ON UPDATE NO ACTION,
	KEY `FK_EMPLOYEE2ADDSERVICEBOOKING_EMPLOYEE` (`EmployeeOid`),
	CONSTRAINT `FK_EMPLOYEE2ADDSERVICEBOOKING_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 `supportpin` (
	`Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
	`Pin` VARCHAR(5) DEFAULT NULL,
	`IsUsed` TINYINT DEFAULT 0,
	`CreationDate` DATETIME DEFAULT NULL,
	`ExpirationDate` DATETIME DEFAULT NULL,
	`UsingDate` DATETIME DEFAULT NULL,
	`IsActive` TINYINT(1) DEFAULT NULL,
	`Tid` INT(10) DEFAULT NULL,
	`Notice` VARCHAR(1024) DEFAULT NULL,
	`InsTs` datetime DEFAULT NULL,
    `InsUser` VARCHAR(256) DEFAULT NULL,
    `UdpUser` VARCHAR(256) DEFAULT NULL,
    `SystemEntryID` INT(10) DEFAULT NULL,
    `Version` bigint(19) DEFAULT NULL,
	PRIMARY KEY(`Oid`),
	CONSTRAINT `UniquePin` UNIQUE(`Pin`)
) ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `resourceappointment` (
	`Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
	`FormerBookingOid` BIGINT(19) DEFAULT NULL,
	`FormerBookingSequenceOid` BIGINT(19) DEFAULT NULL,
	`Tid` INT(10) DEFAULT NULL,
	`IsActive` TINYINT(1) DEFAULT NULL,
	`Notice` mediumtext,
	`InsTs` datetime,
	`InsUser` varchar(256) DEFAULT NULL,
	`Version` bigint(19),
	`UdpUser` varchar(256),
	`SystemEntryID` int(10),
	`Type` int(11),
	`StartDate` datetime,
	`EndDate` datetime,
	`AllDay` bit(1),
	`Subject` varchar(256) DEFAULT NULL,
	`Location` varchar(256) DEFAULT NULL,
	`Status` int(11),
	`RecurrenceInfo` mediumtext,
	`ReminderInfo` mediumtext,
	`ResourceOid` BIGINT(19),
	`EmployeeOid` BIGINT(19),
	PRIMARY KEY(`Oid`),
	KEY `FK_BOOKING2RESOURCEAPPOINTMENT` (`FormerBookingOid`),
	CONSTRAINT `FK_BOOKING2RESOURCEAPPOINTMENT`
		FOREIGN KEY (`FormerBookingOid`)
		REFERENCES `resourcebooking` (`Oid`)
		ON DELETE NO ACTION ON UPDATE NO ACTION,
	KEY `FK_BOOKINGSEQUENCE2RESOURCEAPPOINTMENT` (`FormerBookingSequenceOid`),
	CONSTRAINT `FK_BOOKINGSEQUENCE2RESOURCEAPPOINTMENT`
		FOREIGN KEY (`FormerBookingSequenceOid`)
		REFERENCES `resourcebookingsequence` (`Oid`)
		ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `auszahlungsart` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Tid` int(10) DEFAULT NULL,
  `IsActive` tinyint(1) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `Name` varchar(256) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;

	
CREATE TABLE `overtime` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Tid` int(10) DEFAULT NULL,
  `IsActive` tinyint(1) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `EmployeeOid` bigint(19) DEFAULT NULL,
  `Datum` datetime DEFAULT NULL,
  `Betrag` DECIMAL(18,10) DEFAULT NULL,
  `AuszahlungsartOid` bigint(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `FK_EMPLOYEE2OVERTIME` (`EmployeeOid`),
  KEY `FK_AUSZAHLUNGSKATEGORIE2OVERTIME` (`AuszahlungsartOid`),
  CONSTRAINT `FK_AUSZAHLUNGSKATEGORIE2OVERTIME` FOREIGN KEY (`AuszahlungsartOid`) REFERENCES `auszahlungsart` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_EMPLOYEE2OVERTIME` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;



CREATE TABLE `NewSchedulerAppointment` (
	`Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  	`Tid` int(10) DEFAULT NULL,
  	`IsActive` tinyint(1) DEFAULT NULL,
  	`Notice` varchar(1024) DEFAULT NULL,
  	`InsTs` datetime DEFAULT NULL,
  	`InsUser` varchar(256) DEFAULT NULL,
  	`Version` bigint(19) DEFAULT NULL,
  	`UdpUser` varchar(256) DEFAULT NULL,
  	`SystemEntryID` int(10) DEFAULT NULL,
	`OriginatorOid` bigint(19) DEFAULT NULL,
	`IsPrivate` tinyint(1) DEFAULT 0,
	`Type` int(11) DEFAULT NULL,
	`StartDate` datetime DEFAULT NULL,
	`EndDate` datetime DEFAULT NULL,
	`AllDay` bit(1) DEFAULT NULL,
	`Subject` varchar(256) DEFAULT NULL,
	`Location` varchar(256) DEFAULT NULL,
	`Status` int(11) DEFAULT NULL,
	`RecurrenceInfo` mediumtext,
	`ReminderInfo` mediumtext,
	`FormerBookingSequenceOid` bigint(19) DEFAULT NULL,
	PRIMARY KEY (`Oid`),
	KEY `FK_ORIGINATOR2NEWSCHAPP` (`OriginatorOid`),
	CONSTRAINT `FK_ORIGINATOR2NEWSCHAPP` FOREIGN KEY (`OriginatorOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;

CREATE TABLE `Customer2NewSchApp` (
	`Oid` bigint(19) NOT NULL AUTO_INCREMENT,
	`CustomerOid` bigint(19) DEFAULT NULL,
	`NewSchAppOid` bigint(19) DEFAULT NULL,
	PRIMARY KEY (`Oid`),
	KEY `FK_CUSTOMER2NEWSCHAPP` (`CustomerOid`),
	CONSTRAINT `FK_CUSTOMER2NEWSCHAPP` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
	KEY `FK_CUSTOMERLINK2NEWSCHAPP` (`NewSchAppOid`),
	CONSTRAINT `FK_CUSTOMERLINK2NEWSCHAPP` FOREIGN KEY (`NewSchAppOid`) REFERENCES `NewSchedulerAppointment` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;

CREATE TABLE `Employee2NewSchApp` (
	`Oid` bigint(19) NOT NULL AUTO_INCREMENT,
	`EmployeeOid` bigint(19) DEFAULT NULL,
	`NewSchAppOid` bigint(19) DEFAULT NULL,
	`IsParticipating` tinyint(3) DEFAULT 0,
	`Tid` VARCHAR(1024) NULL DEFAULT NULL,
	`Notice` VARCHAR(1024) NULL DEFAULT NULL,
	`InsTs` datetime NULL DEFAULT NULL,
	`InsUser` VARCHAR(256) NULL DEFAULT NULL,
	`UdpUser` VARCHAR(256) NULL DEFAULT NULL,
	`Version` BIGINT(19) NULL DEFAULT NULL,
	`IsActive` TINYINT(4) NULL DEFAULT NULL,
	`SystemEntryID` INT(10) NULL DEFAULT NULL,
	`IsPChanged` TINYINT(1) NULL DEFAULT 0,
	`IsPC_CheckedTs` DATETIME NULL DEFAULT NULL,
	PRIMARY KEY (`Oid`),
	KEY `FK_EMPLOYEE2NEWSCHAPP` (`EmployeeOid`),
	CONSTRAINT `FK_EMPLOYEE2NEWSCHAPP` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
	KEY `FK_EMPLOYEELINK2NEWSCHAPP` (`NewSchAppOid`),
	CONSTRAINT `FK_EMPLOYEELINK2NEWSCHAPP` FOREIGN KEY (`NewSchAppOid`) REFERENCES `NewSchedulerAppointment` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;


CREATE TABLE `Resource2NewSchApp` (
	`Oid` bigint(19) NOT NULL AUTO_INCREMENT,
	`ResourceOid` bigint(19) DEFAULT NULL,
	`NewSchAppOid` bigint(19) DEFAULT NULL,
	PRIMARY KEY (`Oid`),
	KEY `FK_RESOURCE2NEWSCHAPP` (`ResourceOid`),
	CONSTRAINT `FK_RESOURCE2NEWSCHAPP` FOREIGN KEY (`ResourceOid`) REFERENCES `resource` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
	KEY `FK_RESOURCELINK2NEWSCHAPP` (`NewSchAppOid`),
	CONSTRAINT `FK_RESOURCELINK2NEWSCHAPP` FOREIGN KEY (`NewSchAppOid`) REFERENCES `NewSchedulerAppointment` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;


CREATE TABLE `medart`(
	`Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  	`Tid` int(10) DEFAULT NULL,
  	`IsActive` tinyint(1) DEFAULT NULL,
  	`Notice` varchar(1024) DEFAULT NULL,
  	`InsTs` datetime DEFAULT NULL,
  	`InsUser` varchar(256) DEFAULT NULL,
  	`Version` bigint(19) DEFAULT NULL,
  	`UdpUser` varchar(256) DEFAULT NULL,
  	`SystemEntryID` int(10) DEFAULT NULL,
	`Bezeichnung` varchar(1024) DEFAULT NULL,
	`BezeichnungLang` varchar(1024) DEFAULT NULL,
	PRIMARY KEY (`Oid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;

CREATE TABLE `medikamentenverordnung` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Tid` int(10) DEFAULT NULL,
  `IsActive` tinyint(1) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `CustomerOid` bigint(19) DEFAULT NULL,
  `MedArtOid` bigint(19) DEFAULT NULL,
  `Darreichungsform` int(2) DEFAULT NULL,
  `Morgens` double DEFAULT NULL,
  `Mittags` double DEFAULT NULL,
  `Abends` double DEFAULT NULL,
  `Nachts` double DEFAULT NULL,
  `DepotMenge` tinyint(1) DEFAULT NULL,
  `DepotRhythmus` int(2) DEFAULT NULL,
  `DepotErsterTag` datetime DEFAULT NULL,
  `DepotNaechsterTag` datetime DEFAULT NULL,
  `MedBemerkung` varchar(1024) DEFAULT NULL,
  `MedVerordnet` varchar(256) DEFAULT NULL,
  `MedName` varchar(1024) DEFAULT NULL,
  `DarreichungsformOid` BIGINT(19) DEFAULT NULL,
  `DepotRhythmusOid` BIGINT(19) DEFAULT NULL,
  `Verordnungsdatum` DATETIME DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `FK_CUSTOMER2MEDVERORDNUNG` (`CustomerOid`),
  KEY `FK_MEDART2MEDVERORDNUNG` (`MedArtOid`),
  CONSTRAINT `FK_CUSTOMER2MEDVERORDNUNG` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_DARFORM2MEDVERORDNUNG` FOREIGN KEY (`DarreichungsformOid`) REFERENCES `medverorddarform` (`Oid`)  ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_DEPRHYTHM2MEDVERORDNUNG` FOREIGN KEY (`DepotRhythmusOid`) REFERENCES `medverorddepotrhythmus` (`Oid`)  ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_MEDART2MEDVERORDNUNG` FOREIGN KEY (`MedArtOid`) REFERENCES `medart` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;


CREATE TABLE `resetpassword` (
	`Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  	`Tid` INT(10) DEFAULT NULL,
  	`IsActive` TINYINT(1) DEFAULT NULL,
  	`Notice` VARCHAR(1024) DEFAULT NULL,
  	`InsTs` DATETIME DEFAULT NULL,
  	`InsUser` VARCHAR(256) DEFAULT NULL,
  	`Version` BIGINT(19) DEFAULT NULL,
  	`UdpUser` VARCHAR(256) DEFAULT NULL,
  	`SystemEntryID` INT(10) DEFAULT NULL,
	`Code` VARCHAR(10) DEFAULT NULL,
	`HasToChangePW` TINYINT(1) DEFAULT 0,
	`ResetDate` DATETIME DEFAULT NULL,
	PRIMARY KEY (`Oid`)
) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=LATIN1;

CREATE TABLE `appuser2resetpassword`(
	`Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
	`ApplicationUserOid` BIGINT(19) DEFAULT NULL,
	`ResetPasswordOid` BIGINT(19) DEFAULT NULL,
	PRIMARY KEY (`Oid`),
	KEY `FK_APPLICATIONUSER` (`ApplicationUserOid`),
	CONSTRAINT `FK_APPLICATIONUSER` FOREIGN KEY (`ApplicationUserOid`) REFERENCES `applicationuser` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
	KEY `FK_RESETPASSWORD` (`ResetPasswordOid`),
	CONSTRAINT `FK_RESETPASSWORD` FOREIGN KEY (`ResetPasswordOid`) REFERENCES `resetpassword` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=LATIN1;

CREATE TABLE `medikamentenverordnungsliste` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Tid` int(10) DEFAULT NULL,
  `IsActive` tinyint(1) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `Gueltig` tinyint(1) DEFAULT NULL,
  `CustomerOid` bigint(19) DEFAULT NULL,
  `MedListType` TINYINT(1) DEFAULT 0,
  PRIMARY KEY (`Oid`),
  KEY `FK_MEDIVERORDNUNGSLISTE2CUSTOMER_idx` (`CustomerOid`),
  CONSTRAINT `FK_MEDIVERORDNUNGSLISTE2CUSTOMER` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=LATIN1;

CREATE TABLE `mediverordnung2mediverordnungsliste` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `MediVerordnungsOid` bigint(19) DEFAULT NULL,
  `MediVerordnungslistenOid` bigint(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `FK_MEDIVERORDNUNG2MV2MVLISTE` (`MediVerordnungsOid`),
  KEY `FK_MEDIVERORDNUNGSLISTE2MV2MVLISTE` (`MediVerordnungslistenOid`),
  CONSTRAINT `FK_MEDIVERORDNUNG2MV2MVLISTE` FOREIGN KEY (`MediVerordnungsOid`) REFERENCES `medikamentenverordnung` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_MEDIVERORDNUNGSLISTE2MV2MVLISTE` FOREIGN KEY (`MediVerordnungslistenOid`) REFERENCES `medikamentenverordnungsliste` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=LATIN1;

CREATE TABLE bewomobilbrowserinfo (
	`Oid` bigint(19) NOT NULL AUTO_INCREMENT,
	`InsTs` datetime DEFAULT NULL,
	`Tenant`varchar(256),
	`Type` varchar(256) DEFAULT NULL,
	`Name` varchar(256) DEFAULT NULL,
	`Version` varchar(256) DEFAULT NULL,
	`Platform` varchar(256) DEFAULT NULL,
	PRIMARY KEY (`Oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `UIElement` (
	`Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
	`Tid` INT(10) DEFAULT NULL,
	`IsActive` TINYINT(1) DEFAULT NULL,
	`Notice` VARCHAR(1024) DEFAULT NULL,
	`InsTs` DATETIME DEFAULT NULL,
	`InsUser` VARCHAR(256) DEFAULT NULL,
	`Version` BIGINT(19) DEFAULT NULL,
	`UdpUser` VARCHAR(256) DEFAULT NULL,
	`SystemEntryID` INT(10) DEFAULT NULL,
	`UIElementType` INT(10) DEFAULT NULL,
	`Xaml` TEXT DEFAULT NULL,
	`EmployeeOid` bigint(19) NULL,
	`TeamOid` bigint(19) NULL,
	PRIMARY KEY (`Oid`),
  KEY `EMPLOYEE_UIELEMENT_FK` (`EmployeeOid`),
  KEY `TEAM_UIELEMENT_FK` (`TeamOid`),
  CONSTRAINT `FK_EMPLOYEE_UIELEMENT` FOREIGN KEY (`EmployeeOid`) REFERENCES `Employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_TEAM_UIELEMENT` FOREIGN KEY (`TeamOid`) REFERENCES `Team` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=LATIN1;

CREATE TABLE MedVerordDarForm (
	`Oid` bigint(19) NOT NULL AUTO_INCREMENT,
	`Tid` int(10) DEFAULT NULL,
	`IsActive` tinyint(1) DEFAULT NULL,
	`Notice` varchar(1024) DEFAULT NULL,
	`InsTs` datetime DEFAULT NULL,
	`InsUser` varchar(256) DEFAULT NULL,
	`Version` bigint(19) DEFAULT NULL,
	`UdpUser` varchar(256) DEFAULT NULL,
	`SystemEntryID` int(10) DEFAULT NULL,
	`Bezeichnung` varchar(256) DEFAULT NULL,
	`Wert` int(10) DEFAULT NULL,
	CONSTRAINT UCWERT UNIQUE (`Wert`),
	PRIMARY KEY (`Oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE MedVerordDepotRhythmus (
	`Oid` bigint(19) NOT NULL AUTO_INCREMENT,
	`Tid` int(10) DEFAULT NULL,
	`IsActive` tinyint(1) DEFAULT NULL,
	`Notice` varchar(1024) DEFAULT NULL,
	`InsTs` datetime DEFAULT NULL,
	`InsUser` varchar(256) DEFAULT NULL,
	`Version` bigint(19) DEFAULT NULL,
	`UdpUser` varchar(256) DEFAULT NULL,
	`SystemEntryID` int(10) DEFAULT NULL,
	`Bezeichnung` varchar(256) DEFAULT NULL,
	`Wert` int(10) DEFAULT NULL,
	CONSTRAINT UCWERT UNIQUE (`Wert`),
	PRIMARY KEY (`Oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `textbaustein` (
	`Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
	`Tid` INT(10) DEFAULT NULL,
	`IsActive` TINYINT(1) DEFAULT NULL,
	`Notice` VARCHAR(1024) DEFAULT NULL,
	`InsTs` DATETIME DEFAULT NULL,
	`InsUser` VARCHAR(256) DEFAULT NULL,
	`Version` BIGINT(19) DEFAULT NULL,
	`UdpUser` VARCHAR(256) DEFAULT NULL,
	`SystemEntryID` INT(10) DEFAULT NULL,
	`Text` VARCHAR(2048) DEFAULT NULL,
	`Position` INT(10) DEFAULT NULL,
	`Name` VARCHAR(256) DEFAULT NULL,
	`ServiceCategoryOid` BIGINT(19) DEFAULT NULL,
	`EmployeeOid` BIGINT(19) DEFAULT NULL,
	`IsOnlyForEmployee` TINYINT(1) DEFAULT NULL,
	`IsParent` TINYINT(1) DEFAULT NULL,
	`ParentOid` BIGINT(19) DEFAULT NULL,
	`IsExpanded` TINYINT(4) DEFAULT NULL,
	PRIMARY KEY (`Oid`),
	KEY `SERVICECATEGORY_TEXTBAUSTEIN_FK` (`ServiceCategoryOid`),
	KEY `EMPLOYEE_TEXTBAUSTEIN_FK` (`EmployeeOid`),
	CONSTRAINT `FK_SERVICECATEGORY_TEXTBAUSTEIN` FOREIGN KEY (`ServiceCategoryOid`) REFERENCES `ServiceCategory` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
	CONSTRAINT `FK_EMPLOYEE_TEXTBAUSTEIN` FOREIGN KEY (`EmployeeOid`) REFERENCES `Employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
	CONSTRAINT FK_TEXTBAUSTEIN2PARENT FOREIGN KEY (ParentOid) REFERENCES textbaustein(Oid) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=LATIN1;

CREATE TABLE bargeldtransaktion(
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
	`Tid` INT(10) DEFAULT NULL,
	`IsActive` TINYINT(1) DEFAULT NULL,
	`Notice` VARCHAR(1024) DEFAULT NULL,
	`InsTs` DATETIME DEFAULT NULL,
	`InsUser` VARCHAR(256) DEFAULT NULL,
	`Version` BIGINT(19) DEFAULT NULL,
	`UdpUser` VARCHAR(256) DEFAULT NULL,
	`SystemEntryID` INT(10) DEFAULT NULL,
  `Zahlungstyp` TINYINT(1) DEFAULT NULL,
  `Betrag` DECIMAL(18,10) DEFAULT NULL,
  `Transaktionskassenbestand` DECIMAL(18, 10) DEFAULT NULL,
  `CustomerOid` BIGINT(19) DEFAULT NULL,
  `Zahlungsdatum` DATETIME DEFAULT NULL,
  `BargeldkassenOid` BIGINT(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `BARGELDTRANSAKTION_CUSTOMER_FK` (`CustomerOid`),
  CONSTRAINT `FK_BARGELDTRANSAKTION_BARGELDKASSE` FOREIGN KEY (`BargeldkassenOid`) REFERENCES `bargeldkasse` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=LATIN1;


CREATE TABLE `behinderungsart2customer` (
	`Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
	`Behinderungsart` TINYINT(4) DEFAULT NULL,
	`CustomerOid` BIGINT(19) DEFAULT NULL,
	PRIMARY KEY (`Oid`),
	KEY `BEHINDERUNGSART_CUSTOMER_FK` (`CustomerOid`),
	CONSTRAINT `FK_BEHINDERUNGSART_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 `merkzeichen2customer` (
	`Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
	`Merkzeichen` TINYINT(4) DEFAULT NULL,
	`CustomerOid` BIGINT(19) DEFAULT NULL,
	PRIMARY KEY (`Oid`),
	KEY `MERKZEICHEN_CUSTOMER_FK` (`CustomerOid`),
	CONSTRAINT `FK_MERKZEICHEN_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 `wohnheim` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `Tid` int(10) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `WohnheimName` varchar(256) DEFAULT NULL,
  `Strasse` varchar(256) DEFAULT NULL,
  `PLZ` varchar(256) DEFAULT NULL,
  `Ort` varchar(256) DEFAULT NULL,
  `Bemerkung` varchar(1024) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=latin1;

CREATE TABLE `customer2wohnheim` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `WohnheimOid` bigint(19) DEFAULT NULL,
  `CustomerOid` bigint(19) DEFAULT NULL,
  `Tid` int(10) DEFAULT NULL,
  `Notice` varchar(1024) 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`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;

CREATE TABLE `employee2wohnheim` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `WohnheimOid` bigint(19) DEFAULT NULL,
  `EmployeeOid` bigint(19) DEFAULT NULL,
  `Tid` int(10) DEFAULT NULL,
  `Notice` varchar(1024) 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`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;



CREATE TABLE `signature` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `ServiceRecordOid` bigint(19) DEFAULT NULL,
  `Tid` int(10) DEFAULT NULL,
  `Notice` varchar(1024) 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,
  `Latitute` varchar(1024) DEFAULT NULL,
  `Longitute` varchar(1024) DEFAULT NULL,
  `Zeitstempel` datetime DEFAULT NULL,
  `DataBild` longtext,
  PRIMARY KEY (`Oid`)
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=latin1;


CREATE TABLE `wohnheimbuchung` (
	`Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
	`InsTs` DATETIME DEFAULT NULL,
	`InsUser` VARCHAR(256) DEFAULT NULL,
	`Notice` VARCHAR(1024) DEFAULT NULL,
	`Tid` INT(10) DEFAULT NULL,
	`UdpUser` VARCHAR(256) DEFAULT NULL,
	`Version` BIGINT(19) DEFAULT NULL,
	`IsActive` TINYINT(4) DEFAULT NULL,
	`SystemEntryID` INT(10) DEFAULT NULL,
	`Buchungsdatum` DATETIME DEFAULT NULL,
	`WohnheimOid` BIGINT(19) DEFAULT NULL,
	PRIMARY KEY (`Oid`),
	KEY `WOHNHEIMBUCHUNG_WOHNHEIM_FK` (`WohnheimOid`),
	CONSTRAINT `FK_WOHNHEIMBUCHUNG_WOHNHEIM` FOREIGN KEY (`WohnheimOid`) REFERENCES `Wohnheim` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `wohnheimbuchung2costbearer2supportconcept` (
	`Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
	`InsTs` DATETIME DEFAULT NULL,
	`InsUser` VARCHAR(256) DEFAULT NULL,
	`Notice` VARCHAR(1024) DEFAULT NULL,
	`Tid` INT(10) DEFAULT NULL,
	`UdpUser` VARCHAR(256) DEFAULT NULL,
	`Version` BIGINT(19) DEFAULT NULL,
	`IsActive` TINYINT(4) DEFAULT NULL,
	`SystemEntryID` INT(10) DEFAULT NULL,
	`StartDate` DATETIME DEFAULT NULL,
	`EndDate` DATETIME DEFAULT NULL,
	`WohnheimbuchungsOid` BIGINT(19) DEFAULT NULL,
	`Costbearer2SupportConceptOid` BIGINT(19) DEFAULT NULL,
	PRIMARY KEY (`Oid`),
	KEY `WOHNHEIMBUCHUNG2CB2SC_FK` (`WohnheimbuchungsOid`),
	CONSTRAINT `FK_WOHNHEIMBUCHUNG2CB2SC_WOHNHEIMBUCHUNG` FOREIGN KEY (`WohnheimbuchungsOid`) REFERENCES `Wohnheimbuchung` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
	KEY `WOHNHEIMBUCHUNG2CB2SC_COSTBEARER2SUPPORTCONCEPT_FK` (`Costbearer2SupportConceptOid`),
	CONSTRAINT `FK_WOHNHEIMBUCHUNG2CB2SC_COSTBEARER2SUPPORTCONCEPT` FOREIGN KEY (`Costbearer2SupportConceptOid`) REFERENCES `Costbearer2SupportConcept` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `wohnheimbuchung2employee` (
	`Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
	`InsTs` DATETIME DEFAULT NULL,
	`InsUser` VARCHAR(256) DEFAULT NULL,
	`Notice` VARCHAR(1024) DEFAULT NULL,
	`Tid` INT(10) DEFAULT NULL,
	`UdpUser` VARCHAR(256) DEFAULT NULL,
	`Version` BIGINT(19) DEFAULT NULL,
	`IsActive` TINYINT(4) DEFAULT NULL,
	`SystemEntryID` INT(10) DEFAULT NULL,
	`StartDate` DATETIME DEFAULT NULL,
	`EndDate` DATETIME DEFAULT NULL,
	`WohnheimbuchungsOid` BIGINT(19) DEFAULT NULL,
	`EmployeeOid` BIGINT(19) DEFAULT NULL,
	PRIMARY KEY (`Oid`),
	KEY `WOHNHEIMBUCHUNG2EMPLOYEE_WOHNHEIMBUCHUNG_FK` (`WohnheimbuchungsOid`),
	CONSTRAINT `FK_WOHNHEIMBUCHUNG2EMPLOYEE_WOHNHEIMBUCHUNG` FOREIGN KEY (`WohnheimbuchungsOid`) REFERENCES `Wohnheimbuchung` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
	KEY `WOHNHEIMBUCHUNG2EMPLOYEE_EMPLOYEE_FK` (`EmployeeOid`),
	CONSTRAINT `FK_WOHNHEIMBUCHUNG2EMPLOYEE_EMPLOYEE` FOREIGN KEY (`EmployeeOid`) REFERENCES `Employee` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE supportconceptapprovalperiod2employee (
	`Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
	`Tid` INT(10) DEFAULT NULL,
	`IsActive` TINYINT(1) DEFAULT NULL,
	`Notice` VARCHAR(1024) DEFAULT NULL,
	`InsTs` DATETIME DEFAULT NULL,
	`InsUser` VARCHAR(256) DEFAULT NULL,
	`Version` BIGINT(19) DEFAULT NULL,
	`UdpUser` VARCHAR(256) DEFAULT NULL,
	`SystemEntryID` INT(10) DEFAULT NULL,
	`SupportConceptApprovalPeriodOid` BIGINT(19) DEFAULT NULL,
	`EmployeeOid` BIGINT(19) DEFAULT NULL,
	`Betreuungsschluessel` DECIMAL(18, 10) DEFAULT NULL,
	`IsAbsolut` INT(10) NULL DEFAULT 0,
	PRIMARY KEY (`Oid`),
	KEY `SUPPORTCONCEPTAPPROVALPERIOD2EMPLOYEE_PERIOD_FK` (`SupportConceptApprovalPeriodOid`),
    CONSTRAINT `FK_SUPPORTCONCEPTAPPROVALPERIOD2EMPLOYEE_PERIOD` FOREIGN KEY (`SupportConceptApprovalPeriodOid`) REFERENCES `SupportConceptApprovalPeriod` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
	KEY `SUPPORTCONCEPTAPPROVALPERIOD2EMPLOYEE_EMPLOYEE_FK` (`EmployeeOid`),
    CONSTRAINT `FK_SUPPORTCONCEPTAPPROVALPERIOD2EMPLOYEE_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 bargeldkasse (
    `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
	`Tid` INT(10) DEFAULT NULL,
	`IsActive` TINYINT(1) DEFAULT NULL,
	`Notice` VARCHAR(1024) DEFAULT NULL,
	`InsTs` DATETIME DEFAULT NULL,
	`InsUser` VARCHAR(256) DEFAULT NULL,
	`Version` BIGINT(19) DEFAULT NULL,
	`UdpUser` VARCHAR(256) DEFAULT NULL,
	`SystemEntryID` INT(10) DEFAULT NULL,
    `ObjectOid` BIGINT(19) DEFAULT NULL,
    `ObjectTid` INT(10) DEFAULT NULL,
    `Kassenname` VARCHAR(256) DEFAULT NULL,
    `Auszahlungsintervall` TINYINT(10) DEFAULT NULL,
    PRIMARY KEY (`Oid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `image` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `CustomerOid` bigint(19) DEFAULT NULL,
  `EmployeeOid` bigint(19) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `Tid` int(10) DEFAULT NULL,
  `UpdUser` varchar(256) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `Original` longblob,
  `MediumThumbnail` longblob,
  `SmallThumbnail` longblob,
  `PersonOid` bigint(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `KEY_CUSTOMER` (`CustomerOid`),
  KEY `KEY_EMPLOYEE` (`EmployeeOid`),
  CONSTRAINT `FK_CUSTOMER` FOREIGN KEY (`CustomerOid`) REFERENCES `customer` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_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 `chatbewomessagesync` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT COMMENT '',
  `EmployeeOid` BIGINT(19) NULL COMMENT '',
  `Tid` INT(10) NULL COMMENT '',
  `Notice` VARCHAR(1024) NULL COMMENT '',
  `InsTs` DATETIME NULL COMMENT '',
  `InsUser` VARCHAR(1024) NULL COMMENT '',
  `Version` BIGINT(19) NULL COMMENT '',
  `UdpUser` VARCHAR(256) NULL COMMENT '',
  `isActive` TINYINT(4) NULL COMMENT '',
  `SystemEntryID` INT(10) NULL COMMENT '',
  `MessageSyncText` VARCHAR(1024) NULL COMMENT '',
   PRIMARY KEY (`Oid`)  COMMENT '')
   ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `chatmessages` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `SenderPersonOid` bigint(19) DEFAULT NULL,
  `EmpfaengerPersonOid` bigint(19) DEFAULT NULL,
  `Tid` int(10) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(1024) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `isActive` tinyint(4) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `ChatText` longblob,
  `Uhrzeit` datetime DEFAULT NULL,
  `IstZugestellt` tinyint(4) DEFAULT NULL,
  `IstGelesen` tinyint(4) DEFAULT NULL,
  `TeamOid` bigint(19) DEFAULT NULL,
  `MessageId` VARCHAR(1024) DEFAULT NULL,
  `MediaTyp` INT(10) NULL DEFAULT NULL COMMENT '',
  PRIMARY KEY (`Oid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';


CREATE TABLE `chatmediamessage` (
  `Oid` BIGINT(19) AUTO_INCREMENT COMMENT '',
  `ChatMessageOid` BIGINT(19) NULL COMMENT '',
  `Tid` INT(10) NULL COMMENT '',
  `Notice` VARCHAR(1024) NULL COMMENT '',
  `InsTs` DATETIME NULL COMMENT '',
  `InsUser` VARCHAR(1024) NULL COMMENT '',
  `Version` BIGINT(19) NULL COMMENT '',
  `UdpUser` VARCHAR(256) NULL COMMENT '',
  `isActive` TINYINT(4) NULL COMMENT '',
  `SystemEntryID` INT(10) NULL COMMENT '',
  `Media` LONGBLOB NULL DEFAULT NULL COMMENT '',
  `ImageThumpNail` LONGBLOB NULL DEFAULT NULL COMMENT '',
 	PRIMARY KEY (`Oid`),
 	INDEX `ChatMessage_IDX` (`ChatMessageOid` ASC)
 	)ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';


CREATE TABLE `employeeappcode` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
  `Employeeoid` BIGINT(19) NULL,
  `Tid` INT(10) NULL,
  `Notice` VARCHAR(1024) NULL,
  `InsTs` DATETIME NULL,
  `InsUser` VARCHAR(1024) NULL,
  `Version` BIGINT(19) NULL,
  `UdpUser` VARCHAR(256) NULL,
  `IsActive` TINYINT(4) NULL,
  `SystemEntryID` INT(10) NULL,
  `EmployeeCode` VARCHAR(512) NULL,
  `EmployeeCodegenDate` DATETIME NULL,
  `IsChatActive` INT DEFAULT 0,
  `NotfallStatement` VARCHAR(1024) NULL,
  PRIMARY KEY (`Oid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';


CREATE TABLE `customerappcode` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `CustomerOid` bigint(19) DEFAULT NULL,
  `Tid` int(10) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(1024) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `CustomerCodeGenDate` datetime DEFAULT NULL,
  `CustomerCode` varchar(512) DEFAULT NULL,
  `IsChatActive` INT DEFAULT 0,
  `BenutzerName` VARCHAR(1024) NULL DEFAULT NULL,
  `Passwort` VARCHAR(1024) NULL DEFAULT NULL,
  `PasswordHash` VARCHAR(1024) NULL DEFAULT NULL,
   PRIMARY KEY (`Oid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';



CREATE TABLE `passwortverlauf` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT COMMENT '',
  `ApplicationUserOid` BIGINT(19) NULL COMMENT '',
  `Tid` INT(10) NULL COMMENT '',
  `Notice` VARCHAR(1024) NULL COMMENT '',
  `InsTs` DATETIME NULL COMMENT '',
  `InsUser` VARCHAR(1024) NULL COMMENT '',
  `Version` BIGINT(19) NULL COMMENT '',
  `UdpUser` VARCHAR(256) NULL COMMENT '',
  `isActive` TINYINT(4) NULL COMMENT '',
  `SystemEntryID` INT(10) NULL COMMENT '',
  `ErstellDatum` DATETIME NULL COMMENT '',
  `Passwort` VARCHAR(64) NULL COMMENT '',
  `Salt` VARCHAR(128) NULL COMMENT '',
 PRIMARY KEY (`Oid`)  COMMENT '')
ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';


CREATE TABLE `newestchatmessage` (
	`Oid` BIGINT(19) NOT NULL AUTO_INCREMENT,
	`Tid` INT(10) DEFAULT NULL,
	`IsActive` TINYINT(1) DEFAULT NULL,
	`Notice` VARCHAR(1024) DEFAULT NULL,
	`InsTs` DATETIME DEFAULT NULL,
	`InsUser` VARCHAR(256) DEFAULT NULL,
	`Version` BIGINT(19) DEFAULT NULL,
	`UdpUser` VARCHAR(256) DEFAULT NULL,
	`SystemEntryID` INT(10) DEFAULT NULL,
	`RecipientPersonOid` BIGINT(19) DEFAULT NULL,
	`SenderPersonOid` BIGINT(19) DEFAULT NULL,
	`ChatMessageOid` BIGINT(19) DEFAULT NULL,
	`IsTeam` TINYINT(1) DEFAULT NULL,
	PRIMARY KEY (`Oid`),
	KEY `NEWESTCHATMESSAGE_RECIPIENT_FK` (`RecipientPersonOid`),
	CONSTRAINT `FK_NEWESTCHATMESSAGE_RECIPIENT` FOREIGN KEY (`RecipientPersonOid`) REFERENCES `Person` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
	KEY `NEWESTCHATMESSAGE_SENDER_FK` (`SenderPersonOid`),
	CONSTRAINT `FK_NEWESTCHATMESSAGE_SENDER` FOREIGN KEY (`SenderPersonOid`) REFERENCES `Person` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
	KEY `NEWESTCHATMESSAGE_CHATMESSAGE_FK` (`ChatMessageOid`),
	CONSTRAINT `FK_NEWESTCHATMESSAGE_CHATMESSAGE` FOREIGN KEY (`ChatMessageOid`) REFERENCES `ChatMessages` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `vertretung`
 (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT COMMENT '',
  `MitarbeiterOid` BIGINT(19) NULL COMMENT '',
  `KlientOid` BIGINT(19) NULL COMMENT '',
  `Tid` INT(10) NULL COMMENT '',
  `Notice` VARCHAR(1024) NULL COMMENT '',
  `InsTs` DATETIME NULL COMMENT '',
  `InsUser` VARCHAR(1024) NULL COMMENT '',
  `Version` BIGINT(19) NULL COMMENT '',
  `UdpUser` VARCHAR(256) NULL COMMENT '',
  `IsActive` TINYINT(4) NULL COMMENT '',
  `SystemEntryID` INT(10) NULL COMMENT '',
  `VertretungsZeitraumVon` DATETIME NULL COMMENT '',
  `VertretungsZeitraumBis` DATETIME NULL COMMENT '',
  `VertretenderMitarbeiterOid` BIGINT(19) NULL DEFAULT 0 COMMENT '',
  `AbsenceTimeOid` BIGINT(19) NULL DEFAULT NULL COMMENT '',
  PRIMARY KEY (`Oid`)  COMMENT '')
  ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';
  
  CREATE TABLE `kriterien` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT COMMENT '',
  `KlientenOid` BIGINT(19) NULL DEFAULT NULL COMMENT '',
  `Tid` INT(10) NULL DEFAULT NULL COMMENT '',
  `Notice` VARCHAR(1024) NULL DEFAULT NULL COMMENT '',
  `InsTs` DATETIME NULL COMMENT '',
  `InsUser` VARCHAR(1024) NULL COMMENT '',
  `Version` BIGINT(19) NULL COMMENT '',
  `UdpUser` VARCHAR(256) NULL COMMENT '',
  `IsActive` TINYINT(4) NULL COMMENT '',
  `SystemEntryID` INT(10) NULL COMMENT '',
  `AusschlussKriterien` VARCHAR(1024) NULL COMMENT '',
  `WunschKriterien` VARCHAR(1024) NULL COMMENT '',
  PRIMARY KEY (`Oid`)  COMMENT '')
  ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';


CREATE TABLE `arbeitszeit` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT COMMENT '',
  `EmployeeOid` BIGINT(19) NULL COMMENT '',
  `Tid` INT(10) NULL COMMENT '',
  `Notice` VARCHAR(1024) NULL COMMENT '',
  `InsTs` DATETIME NULL COMMENT '',
  `InsUser` VARCHAR(1024) NULL COMMENT '',
  `Version` BIGINT(19) NULL COMMENT '',
  `UdpUser` VARCHAR(256) NULL COMMENT '',
  `isActive` TINYINT(4) NULL COMMENT '',
  `SystemEntryID` INT(10) NULL COMMENT '',
  `GueltigVon` DATETIME NULL COMMENT '',
  `GueltigBis` DATETIME NULL COMMENT '',
  `CustomerOid` bigint(19) DEFAULT NULL,
  `OrganisationOid` bigint(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`)  COMMENT '')
  ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';


CREATE TABLE `arbeitszeiteintrag` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT COMMENT '',
  `ArbeitszeitOid` BIGINT(19) NULL COMMENT '',
  `Tid` INT(10) NULL COMMENT '',
  `Notice` VARCHAR(1024) NULL COMMENT '',
  `InsTs` DATETIME NULL COMMENT '',
  `InsUser` VARCHAR(1024) NULL COMMENT '',
  `Version` BIGINT(19) NULL COMMENT '',
  `UdpUser` VARCHAR(256) NULL COMMENT '',
  `isActive` TINYINT(4) NULL COMMENT '',
  `SystemEntryID` INT(10) NULL COMMENT '',
  `Tag` INT(10) NULL COMMENT '',
  `UhrzeitVon` VARCHAR(256) NULL COMMENT '',
  `UhrzeitBis` VARCHAR(256) NULL COMMENT '',
  `CustomerOid` BIGINT(19) NULL DEFAULT NULL,
  `EmployeeOid` BIGINT(19) NULL DEFAULT NULL,
  PRIMARY KEY (`Oid`)  COMMENT '')
  ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';
  
  
  CREATE TABLE customerteam (
	`Oid` bigint(19) NOT NULL AUTO_INCREMENT,
	`Tid` int(10) DEFAULT NULL,
	`Name` varchar(256) DEFAULT NULL,
	`IsActive` tinyint(4) DEFAULT NULL,
	`Notice` varchar(1024) DEFAULT NULL,
	`InsTs` datetime DEFAULT NULL,
	`InsUser` varchar(256) DEFAULT NULL,
	`UdpUser` varchar(256) DEFAULT NULL,
	`Version` bigint(19) DEFAULT NULL,
	`SystemEntryID` int(10) DEFAULT NULL,
	PRIMARY KEY (`Oid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';



CREATE TABLE `token` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT COMMENT '',
  `Tid` INT(10) NULL COMMENT '',
  `Notice` VARCHAR(1024) NULL COMMENT '',
  `InsTs` DATETIME NULL COMMENT '',
  `InsUser` VARCHAR(1024) NULL COMMENT '',
  `Version` BIGINT(19) NULL COMMENT '',
  `UdpUser` VARCHAR(256) NULL COMMENT '',
  `isActive` TINYINT(4) NULL COMMENT '',
  `SystemEntryID` INT(10) NULL COMMENT '',
  `Beschreibung` VARCHAR(1024) NULL COMMENT '',
  `Typ` TINYINT(4) NULL COMMENT '',
  PRIMARY KEY (`Oid`)  COMMENT '')
  ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';



CREATE TABLE `customer2token` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT COMMENT '',
  `CustomerOid` BIGINT(19) NULL COMMENT '',
  `TokenOid` BIGINT(19) NULL COMMENT '',
  `Tid` INT(10) NULL COMMENT '',
  `Notice` VARCHAR(1024) NULL COMMENT '',
  `InsTs` DATETIME NULL COMMENT '',
  `InsUser` VARCHAR(1024) NULL COMMENT '',
   `Version` BIGINT(19) NULL COMMENT '',
  `UdpUser` VARCHAR(256) NULL COMMENT '',
  `isActive` TINYINT(4) NULL COMMENT '',
  `SystemEntryID` INT(10) NULL COMMENT '',
  PRIMARY KEY (`Oid`)  COMMENT '')
  ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';




CREATE TABLE `employee2token` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT COMMENT '',
  `EmployeeOid` BIGINT(19) NULL COMMENT '',
  `TokenOid` BIGINT(19) NULL COMMENT '',
  `Tid` INT(10) NULL COMMENT '',
  `Notice` VARCHAR(1024) NULL COMMENT '',
  `InsTs` DATETIME NULL COMMENT '',
  `InsUser` VARCHAR(1024) NULL COMMENT '',
  `Version` BIGINT(19) NULL COMMENT '',
  `UdpUser` VARCHAR(256) NULL COMMENT '',
  `isActive` TINYINT(4) NULL COMMENT '',
  `SystemEntryID` INT(10) NULL COMMENT '',
  PRIMARY KEY (`Oid`)  COMMENT '')
  ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';
  
  CREATE TABLE `quittierungscheck` (
  `Oid` BIGINT(19) NOT NULL AUTO_INCREMENT COMMENT '',
  `CustomerOid` BIGINT(19) NULL COMMENT '',
  `Tid` INT(10) NULL COMMENT '',
  `Notice` VARCHAR(1024) NULL COMMENT '',
  `InsTs` DATETIME NULL COMMENT '',
  `InsUser` VARCHAR(1024) NULL COMMENT '',
  `Version` BIGINT(19) NULL COMMENT '',
  `UdpUser` VARCHAR(256) NULL COMMENT '',
  `isActive` TINYINT(4) NULL COMMENT '',
  `SystemEntryID` INT(10) NULL COMMENT '',
  `Monat` DATETIME NULL COMMENT '',
  `QuittierungsbelegGedruckt` TINYINT(4) NULL COMMENT '',
  `QuittierungsbelegUnterschrieben` TINYINT(4) NULL COMMENT '',
  `QuittierungsbelegGedrucktAm` DATETIME NULL DEFAULT NULL,
  `QuittierungsbelegUnterschriebenVon` BIGINT(19) NULL DEFAULT NULL,
  `QuittierungsbelegGedrucktVon` BIGINT(19) NULL DEFAULT NULL,
  PRIMARY KEY (`Oid`)  COMMENT '')
  ENGINE=InnoDB AUTO_INCREMENT=1 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci';

CREATE TABLE `feiertag` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Tid` int(10) DEFAULT NULL,
  `Datum` datetime DEFAULT NULL,
  `Name` varchar(256) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `IsActive` tinyint(4) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;

CREATE TABLE `NotizenKategorie` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Tid` int(10) DEFAULT NULL,
  `IsActive` tinyint(1) DEFAULT NULL,
  `Notice` varchar(1024) DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `ObjectOid` bigint(19) DEFAULT NULL,
  `ObjectTid` int(10) DEFAULT NULL,
  `KategorieName` varchar(256) DEFAULT NULL,
  PRIMARY KEY (`Oid`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;


CREATE TABLE `NotizenEintrag` (
  `Oid` bigint(19) NOT NULL AUTO_INCREMENT,
  `Datum` datetime DEFAULT NULL,
  `Tid` int(10) DEFAULT NULL,
  `IsActive` tinyint(1) DEFAULT NULL,
  `Notice` mediumtext DEFAULT NULL,
  `InsTs` datetime DEFAULT NULL,
  `InsUser` varchar(256) DEFAULT NULL,
  `Version` bigint(19) DEFAULT NULL,
  `UdpUser` varchar(256) DEFAULT NULL,
  `SystemEntryID` int(10) DEFAULT NULL,
  `NotizenKategorieOid` bigint(19) DEFAULT NULL,
  PRIMARY KEY (`Oid`),
  KEY `NOTIZENEINTRAG_KATEGORIE_FK` (`NotizenKategorieOid`),
  CONSTRAINT `FK_NOTIZENEINTRAG_KATEGORIE` FOREIGN KEY (`NotizenKategorieOid`) REFERENCES `NotizenKategorie` (`Oid`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;

CREATE VIEW `listedsupportconcept` AS 
  select 
  	CONCAT(IF(`e2c`.`Oid` is null, 0, `e2c`.`Oid`), '_', IF(`cb2sc`.`Oid` is null, 0, `cb2sc`.`Oid`)) as ID,
    `sc`.`Oid` AS `SupportConceptOid`,
    `sc`.`IsActive` AS `IsActive`,
    `sc`.`Version` AS `Version`,
    `c`.`Oid` AS `CustomerOid`,
    `p`.`FirstName` AS `FirstName`,
    `p`.`LastName` AS `LastName`,
    `p`.`DateOfBirth` AS `DateOfBirth`,
    `a`.`Street` AS `Street`,
    `a`.`PostalCode` AS `PostalCode`,
    `a`.`Town` AS `Town`,
    `cb2sc`.`Oid` AS `CostBearer2SupportConceptOid`,
    `cb2sc`.`Status` AS `Status`,
    `cb2sc`.`RequestedStartDate` AS `RequestedStartDate`,
    `cb2sc`.`RequestedEndDate` AS `RequestedEndDate`,
    `cb2sc`.`ApprovedStartDate` AS `ApprovedStartDate`,
    `cb2sc`.`ApprovedEndDate` AS `ApprovedEndDate`,
    `cb2sc`.`CustomerRefenrenceNumber`,
    `cb`.`Oid` AS `CostBearerOid`,
    `cb`.`ID` AS `CostBearerID`,
    `o`.`Oid` AS `OrganisationOid`,
    `o`.`Name` AS `OrganisationName`,
    `e2c`.`EmployeeOid` AS `EmployeeOid` 
  from 
    (((((((`supportconcept` `sc` join `customer` `c` on((`sc`.`CustomerOid` = `c`.`Oid`))) join `person` `p` on((`c`.`PersonOid` = `p`.`Oid`))) left join `address` `a` on((`p`.`AddressOid` = `a`.`Oid`))) left join `costbearer2supportconcept` `cb2sc` on((`sc`.`Oid` = `cb2sc`.`SupportConceptOid`))) left join `costbearer` `cb` on((`cb2sc`.`CostBearerOid` = `cb`.`Oid`))) left join `organisation` `o` on((`o`.`CostBearerOid` = `cb`.`Oid`))) left join `employee2customer` `e2c` on((`e2c`.`CustomerOid` = `c`.`Oid`))) 
  where 
    (`sc`.`IsActive` <> 0);

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 `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;


