-- MySQL dump 10.8 -- -- Host: localhost Database: CRM2 -- ------------------------------------------------------ -- Server version 4.1.7-standard /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */; -- -- Table structure for table `Address` -- DROP TABLE IF EXISTS `Address`; CREATE TABLE `Address` ( `AddressId` int(10) unsigned NOT NULL auto_increment, `CustomerId` mediumint(8) unsigned NOT NULL default '0', `StreetNumber` char(1) NOT NULL default '', `Street` varchar(20) default NULL, `Address1` varchar(20) default NULL, `Address2` varchar(20) default NULL, `Neighborhood` varchar(10) default NULL, `CityId` smallint(5) unsigned NOT NULL default '0', `PostalCode` varchar(9) NOT NULL default '', `CreatorId` mediumint(8) NOT NULL default '0', `DateCreated` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`AddressId`), KEY `CustomerId` (`CustomerId`), CONSTRAINT `Address_ibfk_1` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Endereços de Customers'; -- -- Dumping data for table `Address` -- /*!40000 ALTER TABLE `Address` DISABLE KEYS */; LOCK TABLES `Address` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Address` ENABLE KEYS */; -- -- Table structure for table `Bank` -- DROP TABLE IF EXISTS `Bank`; CREATE TABLE `Bank` ( `BankId` smallint(3) unsigned NOT NULL default '0', `Name` varchar(100) NOT NULL default '', `Score` int(9) NOT NULL default '0', PRIMARY KEY (`BankId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Listagem de Bancos'; -- -- Dumping data for table `Bank` -- /*!40000 ALTER TABLE `Bank` DISABLE KEYS */; LOCK TABLES `Bank` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Bank` ENABLE KEYS */; -- -- Table structure for table `Business` -- DROP TABLE IF EXISTS `Business`; CREATE TABLE `Business` ( `CustomerId` mediumint(8) unsigned NOT NULL default '0', `Name` varchar(16) NOT NULL default '', `NameAlias` varchar(16) NOT NULL default '', `NationalityId` smallint(5) unsigned NOT NULL default '0', `NumberEmployees` smallint(5) unsigned NOT NULL default '0', UNIQUE KEY `CustomerId` (`CustomerId`), CONSTRAINT `Business_ibfk_1` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Cadastro de Empresas'; -- -- Dumping data for table `Business` -- /*!40000 ALTER TABLE `Business` DISABLE KEYS */; LOCK TABLES `Business` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Business` ENABLE KEYS */; -- -- Table structure for table `CalendarAccess` -- DROP TABLE IF EXISTS `CalendarAccess`; CREATE TABLE `CalendarAccess` ( `ViewerId` mediumint(8) unsigned NOT NULL default '0', `OwnerId` mediumint(8) unsigned NOT NULL default '0', `AccessType` enum('r','rw') NOT NULL default 'r', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`ViewerId`,`OwnerId`), KEY `ViewerId` (`ViewerId`), KEY `OwnerId` (`OwnerId`), CONSTRAINT `CalendarAccess_ibfk_1` FOREIGN KEY (`ViewerId`) REFERENCES `Person` (`CustomerId`), CONSTRAINT `CalendarAccess_ibfk_2` FOREIGN KEY (`OwnerId`) REFERENCES `Person` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `CalendarAccess` -- /*!40000 ALTER TABLE `CalendarAccess` DISABLE KEYS */; LOCK TABLES `CalendarAccess` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `CalendarAccess` ENABLE KEYS */; -- -- Table structure for table `CalendarEvent` -- DROP TABLE IF EXISTS `CalendarEvent`; CREATE TABLE `CalendarEvent` ( `EventId` mediumint(8) unsigned NOT NULL auto_increment, `OwnerId` mediumint(8) unsigned NOT NULL default '0', `BriefDescription` text, `FullDescription` text, `StartDate` datetime NOT NULL default '0000-00-00 00:00:00', `Duration` datetime NOT NULL default '0000-00-00 00:00:00', `AccessLevel` enum('r','rw','private') NOT NULL default 'r', `EventTypeId` smallint(5) unsigned NOT NULL default '0', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', `LinkType` enum('Opportunities','ProductSales','Prospection') default NULL, `LinkId` int(11) default NULL, `LocationId` int(11) default '0', `CreatorId` int(11) NOT NULL default '0', PRIMARY KEY (`EventId`), KEY `AccessLevel` (`AccessLevel`), KEY `OwnerId` (`OwnerId`), KEY `EventTypeId` (`EventTypeId`), KEY `StartDate` (`StartDate`), KEY `Duration` (`Duration`), KEY `LinkType` (`LinkType`), KEY `LocationId` (`LocationId`), CONSTRAINT `CalendarEvent_ibfk_3` FOREIGN KEY (`OwnerId`) REFERENCES `Person` (`CustomerId`), CONSTRAINT `CalendarEvent_ibfk_4` FOREIGN KEY (`EventTypeId`) REFERENCES `CalendarEventType` (`EventTypeId`), CONSTRAINT `CalendarEvent_ibfk_5` FOREIGN KEY (`LocationId`) REFERENCES `CalendarEventLocation` (`LocationId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `CalendarEvent` -- /*!40000 ALTER TABLE `CalendarEvent` DISABLE KEYS */; LOCK TABLES `CalendarEvent` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `CalendarEvent` ENABLE KEYS */; -- -- Table structure for table `CalendarEventLocation` -- DROP TABLE IF EXISTS `CalendarEventLocation`; CREATE TABLE `CalendarEventLocation` ( `LocationId` int(11) NOT NULL auto_increment, `FranchiseId` mediumint(8) unsigned NOT NULL default '0', `Name` varchar(50) NOT NULL default '', `Description` text NOT NULL, `DaysOfWeek` enum('0','1','2','3','4','5','6','7') NOT NULL default '0', `MinNumberParticipant` int(11) NOT NULL default '0', `MaxNumberParticipant` int(11) NOT NULL default '0', PRIMARY KEY (`LocationId`), KEY `FranchiseId` (`FranchiseId`), CONSTRAINT `CalendarEventLocation_ibfk_1` FOREIGN KEY (`FranchiseId`) REFERENCES `Business` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `CalendarEventLocation` -- /*!40000 ALTER TABLE `CalendarEventLocation` DISABLE KEYS */; LOCK TABLES `CalendarEventLocation` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `CalendarEventLocation` ENABLE KEYS */; -- -- Table structure for table `CalendarEventParticipant` -- DROP TABLE IF EXISTS `CalendarEventParticipant`; CREATE TABLE `CalendarEventParticipant` ( `EventId` mediumint(8) unsigned NOT NULL default '0', `ParticipantId` mediumint(8) unsigned NOT NULL default '0', `MasterParticipant` enum('True','False') NOT NULL default 'False', `StartDate` datetime NOT NULL default '0000-00-00 00:00:00', `Duration` datetime NOT NULL default '0000-00-00 00:00:00', `Status` enum('Confirmado','N�o Compareceu','Compareceu') NOT NULL default 'N�o Compareceu', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', `CreatorId` int(11) NOT NULL default '0', KEY `ParticipantId` (`ParticipantId`), KEY `EventId` (`EventId`), KEY `MasterParticipant` (`MasterParticipant`), KEY `Duration` (`Duration`), KEY `StartDate` (`StartDate`), CONSTRAINT `CalendarEventParticipant_ibfk_3` FOREIGN KEY (`EventId`) REFERENCES `CalendarEvent` (`EventId`), CONSTRAINT `CalendarEventParticipant_ibfk_4` FOREIGN KEY (`ParticipantId`) REFERENCES `Person` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `CalendarEventParticipant` -- /*!40000 ALTER TABLE `CalendarEventParticipant` DISABLE KEYS */; LOCK TABLES `CalendarEventParticipant` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `CalendarEventParticipant` ENABLE KEYS */; -- -- Table structure for table `CalendarEventType` -- DROP TABLE IF EXISTS `CalendarEventType`; CREATE TABLE `CalendarEventType` ( `EventTypeId` smallint(5) unsigned NOT NULL auto_increment, `ParentEventTypeId` smallint(5) unsigned default NULL, `GuestAcsess` enum('b','r') NOT NULL default 'b', `EventType` varchar(120) NOT NULL default '', `Description` varchar(255) default NULL, PRIMARY KEY (`EventTypeId`), KEY `ParentEventTypeId` (`ParentEventTypeId`), KEY `GuestAcsess` (`GuestAcsess`), CONSTRAINT `CalendarEventType_ibfk_1` FOREIGN KEY (`ParentEventTypeId`) REFERENCES `CalendarEventType` (`EventTypeId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `CalendarEventType` -- /*!40000 ALTER TABLE `CalendarEventType` DISABLE KEYS */; LOCK TABLES `CalendarEventType` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `CalendarEventType` ENABLE KEYS */; -- -- Table structure for table `City` -- DROP TABLE IF EXISTS `City`; CREATE TABLE `City` ( `CityId` smallint(5) unsigned NOT NULL auto_increment, `StateId` int(11) NOT NULL default '0', `CountryId` int(11) NOT NULL default '0', `Name` varchar(85) NOT NULL default '', PRIMARY KEY (`CityId`), FULLTEXT KEY `cidade` (`Name`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Cidades do Mundo'; -- -- Dumping data for table `City` -- /*!40000 ALTER TABLE `City` DISABLE KEYS */; LOCK TABLES `City` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `City` ENABLE KEYS */; -- -- Table structure for table `CommissionShare` -- DROP TABLE IF EXISTS `CommissionShare`; CREATE TABLE `CommissionShare` ( `ShareId` int(11) unsigned NOT NULL auto_increment, `PaymentId` int(11) unsigned NOT NULL default '0', `OriginalShareId` int(11) unsigned default NULL, `SharePercentage` float(5,2) unsigned NOT NULL default '30.00', `FranchiseId` mediumint(8) unsigned default NULL, `ConsultantId` mediumint(8) unsigned default NULL, `DatePaid` date default NULL, `CreatorId` mediumint(8) unsigned NOT NULL default '0', `DateCreated` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`ShareId`), UNIQUE KEY `UniqueCommission` (`PaymentId`,`FranchiseId`,`ConsultantId`,`OriginalShareId`), KEY `PaymentID` (`PaymentId`), KEY `OriginalShareID` (`OriginalShareId`), KEY `FranchiseID` (`FranchiseId`), KEY `ConsultantId` (`ConsultantId`), CONSTRAINT `CommissionShare_ibfk_16` FOREIGN KEY (`PaymentId`) REFERENCES `Payment` (`PaymentId`), CONSTRAINT `CommissionShare_ibfk_17` FOREIGN KEY (`OriginalShareId`) REFERENCES `CommissionShare` (`ShareId`), CONSTRAINT `CommissionShare_ibfk_18` FOREIGN KEY (`FranchiseId`) REFERENCES `Business` (`CustomerId`), CONSTRAINT `CommissionShare_ibfk_19` FOREIGN KEY (`ConsultantId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 PACK_KEYS=0 COMMENT='Comissões de Consultores'; -- -- Dumping data for table `CommissionShare` -- /*!40000 ALTER TABLE `CommissionShare` DISABLE KEYS */; LOCK TABLES `CommissionShare` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `CommissionShare` ENABLE KEYS */; -- -- Table structure for table `Country` -- DROP TABLE IF EXISTS `Country`; CREATE TABLE `Country` ( `CountryId` int(11) NOT NULL auto_increment, `Code` varchar(2) NOT NULL default '', `Name` varchar(33) NOT NULL default '', PRIMARY KEY (`CountryId`), UNIQUE KEY `sigla` (`Code`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Listagem de Países'; -- -- Dumping data for table `Country` -- /*!40000 ALTER TABLE `Country` DISABLE KEYS */; LOCK TABLES `Country` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Country` ENABLE KEYS */; -- -- Table structure for table `Currency` -- DROP TABLE IF EXISTS `Currency`; CREATE TABLE `Currency` ( `CurrencyId` mediumint(4) unsigned NOT NULL auto_increment, `BCCode` mediumint(4) unsigned NOT NULL default '0', `Name` varchar(40) NOT NULL default '', `Symbol` varchar(7) NOT NULL default '', `Pais` varchar(50) NOT NULL default '', `Type` enum('A','B') NOT NULL default 'A', `IsActive` enum('True','False') NOT NULL default 'True', PRIMARY KEY (`CurrencyId`), UNIQUE KEY `BCCode` (`BCCode`), KEY `Status` (`IsActive`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Listagem de Moedas'; -- -- Dumping data for table `Currency` -- /*!40000 ALTER TABLE `Currency` DISABLE KEYS */; LOCK TABLES `Currency` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Currency` ENABLE KEYS */; -- -- Table structure for table `CurrencyRate` -- DROP TABLE IF EXISTS `CurrencyRate`; CREATE TABLE `CurrencyRate` ( `BCCode` mediumint(4) unsigned NOT NULL default '0', `Date` date NOT NULL default '0000-00-00', `TaxBuy` float NOT NULL default '0', `TaxSell` float NOT NULL default '0', `ParityBuy` float default '0', `ParitySell` float default '0', UNIQUE KEY `DistinctRate` (`Date`,`BCCode`), KEY `BCCode` (`BCCode`), CONSTRAINT `CurrencyRate_ibfk_1` FOREIGN KEY (`BCCode`) REFERENCES `Currency` (`BCCode`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Taxas de Câmbio Diárias'; -- -- Dumping data for table `CurrencyRate` -- /*!40000 ALTER TABLE `CurrencyRate` DISABLE KEYS */; LOCK TABLES `CurrencyRate` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `CurrencyRate` ENABLE KEYS */; -- -- Table structure for table `Customer` -- DROP TABLE IF EXISTS `Customer`; CREATE TABLE `Customer` ( `CustomerId` mediumint(8) unsigned NOT NULL auto_increment, `Type` enum('P','B','R','G') NOT NULL default 'P', `DateCreated` datetime default NULL, `DateUpdated` datetime default NULL, `Description` text, `IsActive` enum('True','False') NOT NULL default 'True', `CreatorId` mediumint(8) unsigned NOT NULL default '0', PRIMARY KEY (`CustomerId`), KEY `Type` (`Type`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Clientes do Sistema'; -- -- Dumping data for table `Customer` -- /*!40000 ALTER TABLE `Customer` DISABLE KEYS */; LOCK TABLES `Customer` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Customer` ENABLE KEYS */; -- -- Table structure for table `CustomerCommission` -- DROP TABLE IF EXISTS `CustomerCommission`; CREATE TABLE `CustomerCommission` ( `CustomerId` mediumint(8) unsigned NOT NULL default '0', `Percentage` float NOT NULL default '0', `ProductId` int(10) NOT NULL default '0', `IsFullCommission` enum('True','False') NOT NULL default 'True', `DateStart` datetime NOT NULL default '0000-00-00 00:00:00', `DateStop` datetime default NULL, `IsActive` enum('True','False') NOT NULL default 'True', KEY `CustomerId` (`CustomerId`,`IsFullCommission`,`IsActive`), CONSTRAINT `CustomerCommission_ibfk_1` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Comissões de um Customer.'; -- -- Dumping data for table `CustomerCommission` -- /*!40000 ALTER TABLE `CustomerCommission` DISABLE KEYS */; LOCK TABLES `CustomerCommission` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `CustomerCommission` ENABLE KEYS */; -- -- Table structure for table `CustomerExternalRelation` -- DROP TABLE IF EXISTS `CustomerExternalRelation`; CREATE TABLE `CustomerExternalRelation` ( `CustomerId` mediumint(8) unsigned NOT NULL default '0', `ExternalSystemId` tinyint(3) unsigned NOT NULL default '0', `ExternalId` mediumint(8) NOT NULL default '0', `Date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, UNIQUE KEY `CustomerId` (`CustomerId`), UNIQUE KEY `DistinctExternalId` (`ExternalSystemId`,`ExternalId`), CONSTRAINT `CustomerExternalRelation_ibfk_1` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`), CONSTRAINT `CustomerExternalRelation_ibfk_2` FOREIGN KEY (`ExternalSystemId`) REFERENCES `ExternalSystem` (`ExternalSystemId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Relaciona Customer com sistemas externos'; -- -- Dumping data for table `CustomerExternalRelation` -- /*!40000 ALTER TABLE `CustomerExternalRelation` DISABLE KEYS */; LOCK TABLES `CustomerExternalRelation` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `CustomerExternalRelation` ENABLE KEYS */; -- -- Table structure for table `CustomerHierarchyLevel` -- DROP TABLE IF EXISTS `CustomerHierarchyLevel`; CREATE TABLE `CustomerHierarchyLevel` ( `CustomerId` mediumint(8) unsigned NOT NULL default '0', `ParentCustomerId` mediumint(8) unsigned default NULL, `IsHeavy` enum('True','False') NOT NULL default 'True', `IsActive` enum('True','False') NOT NULL default 'True', `CreatorId` mediumint(8) unsigned NOT NULL default '0', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', UNIQUE KEY `CustomerId` (`CustomerId`), KEY `ParentCustomerId` (`ParentCustomerId`), CONSTRAINT `CustomerHierarchyLevel_ibfk_1` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`), CONSTRAINT `CustomerHierarchyLevel_ibfk_2` FOREIGN KEY (`ParentCustomerId`) REFERENCES `CustomerHierarchyLevel` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `CustomerHierarchyLevel` -- /*!40000 ALTER TABLE `CustomerHierarchyLevel` DISABLE KEYS */; LOCK TABLES `CustomerHierarchyLevel` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `CustomerHierarchyLevel` ENABLE KEYS */; -- -- Table structure for table `CustomerRole` -- DROP TABLE IF EXISTS `CustomerRole`; CREATE TABLE `CustomerRole` ( `CustomerId` mediumint(8) unsigned NOT NULL default '0', `RoleID` mediumint(3) NOT NULL default '0', UNIQUE KEY `CustomerId` (`CustomerId`), UNIQUE KEY `DistinctRole` (`CustomerId`,`RoleID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=1 COMMENT='Tabela que irá prover compatibilidade entre CRM2 e CRM1'; -- -- Dumping data for table `CustomerRole` -- /*!40000 ALTER TABLE `CustomerRole` DISABLE KEYS */; LOCK TABLES `CustomerRole` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `CustomerRole` ENABLE KEYS */; -- -- Table structure for table `CustomerSector` -- DROP TABLE IF EXISTS `CustomerSector`; CREATE TABLE `CustomerSector` ( `CustomerId` mediumint(8) unsigned NOT NULL default '0', `SectorId` smallint(5) unsigned NOT NULL default '0', UNIQUE KEY `CustomerId` (`CustomerId`), KEY `SectorID` (`SectorId`,`CustomerId`), CONSTRAINT `CustomerSector_ibfk_1` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `CustomerSector` -- /*!40000 ALTER TABLE `CustomerSector` DISABLE KEYS */; LOCK TABLES `CustomerSector` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `CustomerSector` ENABLE KEYS */; -- -- Table structure for table `Document` -- DROP TABLE IF EXISTS `Document`; CREATE TABLE `Document` ( `DocumentId` int(10) unsigned NOT NULL default '0', `DocumentTypeId` tinyint(3) unsigned NOT NULL default '0', `Value` varchar(6) NOT NULL default '', KEY `CustomerId` (`DocumentId`,`DocumentTypeId`), KEY `Value` (`Value`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `Document` -- /*!40000 ALTER TABLE `Document` DISABLE KEYS */; LOCK TABLES `Document` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Document` ENABLE KEYS */; -- -- Table structure for table `DocumentType` -- DROP TABLE IF EXISTS `DocumentType`; CREATE TABLE `DocumentType` ( `DocumentTypeId` tinyint(3) unsigned NOT NULL auto_increment, `Name` varchar(5) NOT NULL default '', `CustomerType` enum('P','B') NOT NULL default 'P', `Nationality` tinyint(3) unsigned NOT NULL default '0', `Required` enum('True','False') NOT NULL default 'False', PRIMARY KEY (`DocumentTypeId`), KEY `Name` (`Name`), KEY `Required` (`Required`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `DocumentType` -- /*!40000 ALTER TABLE `DocumentType` DISABLE KEYS */; LOCK TABLES `DocumentType` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `DocumentType` ENABLE KEYS */; -- -- Table structure for table `Email` -- DROP TABLE IF EXISTS `Email`; CREATE TABLE `Email` ( `EmailId` int(10) unsigned NOT NULL auto_increment, `CustomerId` mediumint(8) unsigned NOT NULL default '0', `EMail` varchar(50) NOT NULL default '', `IsActive` enum('True','False') NOT NULL default 'True', `CreatorId` mediumint(8) NOT NULL default '0', `DateCreated` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`EmailId`), KEY `CustomerId` (`CustomerId`), KEY `EMail` (`EMail`), CONSTRAINT `Email_ibfk_1` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Endereços de e-mail de Customers'; -- -- Dumping data for table `Email` -- /*!40000 ALTER TABLE `Email` DISABLE KEYS */; LOCK TABLES `Email` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Email` ENABLE KEYS */; -- -- Table structure for table `Evaluation` -- DROP TABLE IF EXISTS `Evaluation`; CREATE TABLE `Evaluation` ( `EvaluationId` smallint(5) unsigned NOT NULL auto_increment, `Title` varchar(120) NOT NULL default '', `Description` text, PRIMARY KEY (`EvaluationId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `Evaluation` -- /*!40000 ALTER TABLE `Evaluation` DISABLE KEYS */; LOCK TABLES `Evaluation` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Evaluation` ENABLE KEYS */; -- -- Table structure for table `EvaluationAlternative` -- DROP TABLE IF EXISTS `EvaluationAlternative`; CREATE TABLE `EvaluationAlternative` ( `AlternativeId` smallint(5) unsigned NOT NULL auto_increment, `QuestionId` smallint(5) unsigned NOT NULL default '0', `AlternativeOrder` tinyint(2) unsigned NOT NULL default '0', `Alternative` varchar(255) default NULL, `AnswerWeight` tinyint(3) NOT NULL default '0', PRIMARY KEY (`AlternativeId`), UNIQUE KEY `AlternativeId` (`AlternativeId`,`QuestionId`), KEY `QuestionId` (`QuestionId`), CONSTRAINT `EvaluationAlternative_ibfk_1` FOREIGN KEY (`QuestionId`) REFERENCES `EvaluationQuestion` (`QuestionId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; -- -- Dumping data for table `EvaluationAlternative` -- /*!40000 ALTER TABLE `EvaluationAlternative` DISABLE KEYS */; LOCK TABLES `EvaluationAlternative` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `EvaluationAlternative` ENABLE KEYS */; -- -- Table structure for table `EvaluationProduct` -- DROP TABLE IF EXISTS `EvaluationProduct`; CREATE TABLE `EvaluationProduct` ( `ProductId` tinyint(3) unsigned NOT NULL default '0', `EvaluationId` smallint(5) unsigned NOT NULL default '0', UNIQUE KEY `ProductId` (`ProductId`,`EvaluationId`), KEY `EvaluationId` (`EvaluationId`), CONSTRAINT `EvaluationProduct_ibfk_1` FOREIGN KEY (`ProductId`) REFERENCES `Product` (`ProductId`), CONSTRAINT `EvaluationProduct_ibfk_2` FOREIGN KEY (`EvaluationId`) REFERENCES `Evaluation` (`EvaluationId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `EvaluationProduct` -- /*!40000 ALTER TABLE `EvaluationProduct` DISABLE KEYS */; LOCK TABLES `EvaluationProduct` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `EvaluationProduct` ENABLE KEYS */; -- -- Table structure for table `EvaluationQuestion` -- DROP TABLE IF EXISTS `EvaluationQuestion`; CREATE TABLE `EvaluationQuestion` ( `QuestionId` smallint(5) unsigned NOT NULL auto_increment, `SectionId` smallint(5) unsigned NOT NULL default '0', `EvaluationId` smallint(5) unsigned NOT NULL default '0', `QuestionOrder` tinyint(2) unsigned NOT NULL default '0', `QuestionType` enum('Text','Radio','Select','CheckBox','TextArea') NOT NULL default 'Text', `Question` varchar(255) NOT NULL default '', PRIMARY KEY (`QuestionId`), UNIQUE KEY `SectionId` (`SectionId`,`EvaluationId`,`QuestionOrder`), KEY `EvaluationId` (`EvaluationId`,`QuestionOrder`), CONSTRAINT `EvaluationQuestion_ibfk_1` FOREIGN KEY (`SectionId`) REFERENCES `EvaluationSection` (`SectionId`), CONSTRAINT `EvaluationQuestion_ibfk_2` FOREIGN KEY (`EvaluationId`) REFERENCES `Evaluation` (`EvaluationId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `EvaluationQuestion` -- /*!40000 ALTER TABLE `EvaluationQuestion` DISABLE KEYS */; LOCK TABLES `EvaluationQuestion` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `EvaluationQuestion` ENABLE KEYS */; -- -- Table structure for table `EvaluationRequest` -- DROP TABLE IF EXISTS `EvaluationRequest`; CREATE TABLE `EvaluationRequest` ( `EvaluationRequestId` int(11) NOT NULL auto_increment, `ProductSaleId` mediumint(8) unsigned NOT NULL default '0', `CustomerId` mediumint(8) unsigned NOT NULL default '0', `EvaluationId` smallint(5) unsigned NOT NULL default '0', `DateRequest` datetime NOT NULL default '0000-00-00 00:00:00', `DateReceived` datetime default NULL, `DateCompleted` datetime default NULL, `RespondenteId` mediumint(8) unsigned default '0', PRIMARY KEY (`EvaluationRequestId`), UNIQUE KEY `DenyDuplicate` (`EvaluationRequestId`,`ProductSaleId`,`CustomerId`), KEY `DateReceived` (`DateReceived`), KEY `ProductSaleId` (`ProductSaleId`), KEY `CustomerId` (`CustomerId`), KEY `EvaluationId` (`EvaluationId`), KEY `DateCompleted` (`DateCompleted`), KEY `RespondenteId` (`RespondenteId`), CONSTRAINT `EvaluationRequest_ibfk_1` FOREIGN KEY (`ProductSaleId`) REFERENCES `ProductSale` (`ProductSaleId`), CONSTRAINT `EvaluationRequest_ibfk_2` FOREIGN KEY (`CustomerId`) REFERENCES `Person` (`CustomerId`), CONSTRAINT `EvaluationRequest_ibfk_3` FOREIGN KEY (`EvaluationId`) REFERENCES `Evaluation` (`EvaluationId`), CONSTRAINT `EvaluationRequest_ibfk_4` FOREIGN KEY (`RespondenteId`) REFERENCES `Person` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `EvaluationRequest` -- /*!40000 ALTER TABLE `EvaluationRequest` DISABLE KEYS */; LOCK TABLES `EvaluationRequest` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `EvaluationRequest` ENABLE KEYS */; -- -- Table structure for table `EvaluationResponses` -- DROP TABLE IF EXISTS `EvaluationResponses`; CREATE TABLE `EvaluationResponses` ( `EvaluationRequestId` int(11) NOT NULL default '0', `QuestionId` smallint(5) unsigned NOT NULL default '0', `ProductSaleId` mediumint(8) unsigned NOT NULL default '0', `AlternativeId` smallint(5) unsigned NOT NULL default '0', `CustomerId` mediumint(8) unsigned NOT NULL default '0', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', `Memo` text, PRIMARY KEY (`EvaluationRequestId`,`ProductSaleId`,`AlternativeId`,`CustomerId`), KEY `EvaluationRequestId` (`EvaluationRequestId`), KEY `QuestionId` (`QuestionId`), KEY `ProductSaleId` (`ProductSaleId`), KEY `AlternativeId` (`AlternativeId`), KEY `CustomerId` (`CustomerId`), CONSTRAINT `EvaluationResponses_ibfk_1` FOREIGN KEY (`EvaluationRequestId`) REFERENCES `EvaluationRequest` (`EvaluationRequestId`), CONSTRAINT `EvaluationResponses_ibfk_2` FOREIGN KEY (`QuestionId`) REFERENCES `EvaluationQuestion` (`QuestionId`), CONSTRAINT `EvaluationResponses_ibfk_3` FOREIGN KEY (`ProductSaleId`) REFERENCES `ProductSale` (`ProductSaleId`), CONSTRAINT `EvaluationResponses_ibfk_4` FOREIGN KEY (`AlternativeId`) REFERENCES `EvaluationAlternative` (`AlternativeId`), CONSTRAINT `EvaluationResponses_ibfk_5` FOREIGN KEY (`CustomerId`) REFERENCES `Person` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `EvaluationResponses` -- /*!40000 ALTER TABLE `EvaluationResponses` DISABLE KEYS */; LOCK TABLES `EvaluationResponses` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `EvaluationResponses` ENABLE KEYS */; -- -- Table structure for table `EvaluationSection` -- DROP TABLE IF EXISTS `EvaluationSection`; CREATE TABLE `EvaluationSection` ( `SectionId` smallint(5) unsigned NOT NULL auto_increment, `Title` varchar(255) default NULL, `SectionOrder` tinyint(2) unsigned NOT NULL default '0', `EvaluationId` smallint(5) NOT NULL default '0', PRIMARY KEY (`SectionId`), UNIQUE KEY `SectionId` (`EvaluationId`,`SectionOrder`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `EvaluationSection` -- /*!40000 ALTER TABLE `EvaluationSection` DISABLE KEYS */; LOCK TABLES `EvaluationSection` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `EvaluationSection` ENABLE KEYS */; -- -- Table structure for table `ExternalSystem` -- DROP TABLE IF EXISTS `ExternalSystem`; CREATE TABLE `ExternalSystem` ( `ExternalSystemId` tinyint(3) unsigned NOT NULL auto_increment, `ExternalSystemName` varchar(100) NOT NULL default '', `IsActive` enum('True','False') NOT NULL default 'True', PRIMARY KEY (`ExternalSystemId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Lista de sistemas externos ao CRM'; -- -- Dumping data for table `ExternalSystem` -- /*!40000 ALTER TABLE `ExternalSystem` DISABLE KEYS */; LOCK TABLES `ExternalSystem` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `ExternalSystem` ENABLE KEYS */; -- -- Table structure for table `Group` -- DROP TABLE IF EXISTS `Group`; CREATE TABLE `Group` ( `CustomerId` mediumint(8) unsigned NOT NULL default '0', `Name` varchar(33) NOT NULL default '', `GroupTypeId` tinyint(3) unsigned NOT NULL default '0', `GroupParentId` mediumint(8) unsigned default NULL, UNIQUE KEY `CustomerId` (`CustomerId`), KEY `GroupParentId` (`GroupParentId`), KEY `GroupTypeId` (`GroupTypeId`), KEY `GroupTypeId_2` (`GroupTypeId`), CONSTRAINT `Group_ibfk_1` FOREIGN KEY (`GroupParentId`) REFERENCES `Group` (`CustomerId`), CONSTRAINT `Group_ibfk_2` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`), CONSTRAINT `Group_ibfk_3` FOREIGN KEY (`GroupTypeId`) REFERENCES `GroupType` (`GroupTypeId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Grupos de Customers'; -- -- Dumping data for table `Group` -- /*!40000 ALTER TABLE `Group` DISABLE KEYS */; LOCK TABLES `Group` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Group` ENABLE KEYS */; -- -- Table structure for table `GroupType` -- DROP TABLE IF EXISTS `GroupType`; CREATE TABLE `GroupType` ( `GroupTypeId` tinyint(3) unsigned NOT NULL auto_increment, `GroupTypeName` varchar(255) NOT NULL default '', `GroupTypeIcon` varchar(255) NOT NULL default '', PRIMARY KEY (`GroupTypeId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Tipo de grupo de Customer: Empresa, área, projeto, etc'; -- -- Dumping data for table `GroupType` -- /*!40000 ALTER TABLE `GroupType` DISABLE KEYS */; LOCK TABLES `GroupType` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `GroupType` ENABLE KEYS */; -- -- Table structure for table `InspectionType` -- DROP TABLE IF EXISTS `InspectionType`; CREATE TABLE `InspectionType` ( `InspectionTypeId` smallint(4) unsigned NOT NULL auto_increment, `Description` varchar(255) NOT NULL default '', `IsActive` enum('True','False') NOT NULL default 'True', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', `CreatorId` mediumint(8) unsigned NOT NULL default '0', PRIMARY KEY (`InspectionTypeId`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `InspectionType` -- /*!40000 ALTER TABLE `InspectionType` DISABLE KEYS */; LOCK TABLES `InspectionType` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `InspectionType` ENABLE KEYS */; -- -- Table structure for table `InspectionTypeStatus` -- DROP TABLE IF EXISTS `InspectionTypeStatus`; CREATE TABLE `InspectionTypeStatus` ( `InspectionTypeStatusId` smallint(4) unsigned NOT NULL auto_increment, `InspectionTypeId` smallint(4) unsigned NOT NULL default '0', `IsOK` enum('True','False') NOT NULL default 'True', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', `CreatorId` mediumint(8) unsigned NOT NULL default '0', PRIMARY KEY (`InspectionTypeStatusId`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `InspectionTypeStatus` -- /*!40000 ALTER TABLE `InspectionTypeStatus` DISABLE KEYS */; LOCK TABLES `InspectionTypeStatus` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `InspectionTypeStatus` ENABLE KEYS */; -- -- Table structure for table `Message` -- DROP TABLE IF EXISTS `Message`; CREATE TABLE `Message` ( `MessageId` mediumint(8) NOT NULL auto_increment, `ProductSaleId` mediumint(8) default NULL, `FromCustomerId` mediumint(8) NOT NULL default '0', `ToCustomerId` mediumint(8) NOT NULL default '0', `MessageTypeId` mediumint(8) NOT NULL default '0', `Message` text NOT NULL, `IdOrigin` int(11) NOT NULL default '0', `TransferReceiptType` int(11) NOT NULL default '0', `CreatorId` mediumint(8) NOT NULL default '0', `DateCreated` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`MessageId`), KEY `ProductSaleId` (`ProductSaleId`), KEY `FromCustomerId` (`FromCustomerId`), KEY `ToCustomerId` (`ToCustomerId`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Mensagens de um usuário para outro'; -- -- Dumping data for table `Message` -- /*!40000 ALTER TABLE `Message` DISABLE KEYS */; LOCK TABLES `Message` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Message` ENABLE KEYS */; -- -- Table structure for table `MessageLog` -- DROP TABLE IF EXISTS `MessageLog`; CREATE TABLE `MessageLog` ( `MessageId` mediumint(8) NOT NULL default '0', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', `CreatorId` mediumint(8) NOT NULL default '0', `MessageLogType` enum('a','b') NOT NULL default 'a' ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `MessageLog` -- /*!40000 ALTER TABLE `MessageLog` DISABLE KEYS */; LOCK TABLES `MessageLog` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `MessageLog` ENABLE KEYS */; -- -- Table structure for table `MessageType` -- DROP TABLE IF EXISTS `MessageType`; CREATE TABLE `MessageType` ( `MessageType` smallint(4) unsigned NOT NULL default '0', `MessageTypeName` varchar(100) NOT NULL default '', `From` enum('definir','ainda') NOT NULL default 'definir', `IsActive` enum('True','False') NOT NULL default 'True' ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `MessageType` -- /*!40000 ALTER TABLE `MessageType` DISABLE KEYS */; LOCK TABLES `MessageType` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `MessageType` ENABLE KEYS */; -- -- Table structure for table `Module` -- DROP TABLE IF EXISTS `Module`; CREATE TABLE `Module` ( `ModuleId` int(10) NOT NULL auto_increment, `Name` varchar(33) NOT NULL default '', `Object` varchar(16) default NULL, `DefaultStateId` int(10) default NULL, `ModuleParentId` int(10) default NULL, PRIMARY KEY (`ModuleId`), KEY `ModuleParentId` (`ModuleParentId`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `Module` -- /*!40000 ALTER TABLE `Module` DISABLE KEYS */; LOCK TABLES `Module` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Module` ENABLE KEYS */; -- -- Table structure for table `ModuleState` -- DROP TABLE IF EXISTS `ModuleState`; CREATE TABLE `ModuleState` ( `ModuleId` int(10) NOT NULL default '0', `StateId` int(10) NOT NULL auto_increment, `Name` varchar(33) NOT NULL default '', `Method` varchar(16) NOT NULL default '', PRIMARY KEY (`ModuleId`,`StateId`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `ModuleState` -- /*!40000 ALTER TABLE `ModuleState` DISABLE KEYS */; LOCK TABLES `ModuleState` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `ModuleState` ENABLE KEYS */; -- -- Table structure for table `Nationality` -- DROP TABLE IF EXISTS `Nationality`; CREATE TABLE `Nationality` ( `NationalityId` smallint(5) unsigned NOT NULL auto_increment, `Nationality` varchar(10) NOT NULL default '', `Description` text NOT NULL, PRIMARY KEY (`NationalityId`), KEY `Nationality` (`Nationality`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `Nationality` -- /*!40000 ALTER TABLE `Nationality` DISABLE KEYS */; LOCK TABLES `Nationality` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Nationality` ENABLE KEYS */; -- -- Table structure for table `Payment` -- DROP TABLE IF EXISTS `Payment`; CREATE TABLE `Payment` ( `PaymentId` int(11) unsigned NOT NULL auto_increment, `ProductSaleId` mediumint(8) unsigned NOT NULL default '0', `IsConditionalPayment` enum('False','True') NOT NULL default 'False', `PaymentNumber` tinyint(2) NOT NULL default '0', `OriginalPaymentId` int(11) unsigned default NULL, `DateDue` date default NULL, `DatePaid` date default NULL, `PaymentAccountId` smallint(5) unsigned default NULL, `PaymentTypeId` tinyint(3) unsigned NOT NULL default '0', `CurrencyId` mediumint(4) unsigned NOT NULL default '0', `BankId` smallint(3) unsigned default NULL, `DocId` varchar(10) default NULL, `Value` decimal(9,2) NOT NULL default '0.00', `ValuePaid` decimal(9,2) default NULL, `PaymentStatusId` tinyint(3) NOT NULL default '1', `DateRepass` datetime NOT NULL default '0000-00-00 00:00:00', `DateCommissionPaid` date default NULL, `ReceiptId` varchar(7) default NULL, `DateReceiptRequest` datetime default NULL, `DateReceiptSent` date default NULL, `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', `CreatorId` int(11) NOT NULL default '0', PRIMARY KEY (`PaymentId`), UNIQUE KEY `UniquePayment` (`ProductSaleId`,`IsConditionalPayment`,`PaymentNumber`,`OriginalPaymentId`), KEY `IsConditionalPayment` (`IsConditionalPayment`), KEY `OriginalPaymentID` (`OriginalPaymentId`), KEY `DateDue` (`DateDue`), KEY `DatePaid` (`DatePaid`), KEY `PaymentStatusID` (`PaymentStatusId`), KEY `ProductSaleID` (`ProductSaleId`), KEY `PaymentTypeId` (`PaymentTypeId`), KEY `Currencyid` (`CurrencyId`), KEY `PaymentAccountId` (`PaymentAccountId`), KEY `BankId` (`BankId`), CONSTRAINT `Payment_ibfk_59` FOREIGN KEY (`ProductSaleId`) REFERENCES `ProductSale` (`ProductSaleId`), CONSTRAINT `Payment_ibfk_60` FOREIGN KEY (`OriginalPaymentId`) REFERENCES `Payment` (`PaymentId`), CONSTRAINT `Payment_ibfk_61` FOREIGN KEY (`PaymentAccountId`) REFERENCES `PaymentAccount` (`PaymentAccountId`), CONSTRAINT `Payment_ibfk_62` FOREIGN KEY (`PaymentTypeId`) REFERENCES `PaymentType` (`PaymentTypeId`), CONSTRAINT `Payment_ibfk_63` FOREIGN KEY (`Currencyid`) REFERENCES `Currency` (`BCCode`), CONSTRAINT `Payment_ibfk_64` FOREIGN KEY (`BankId`) REFERENCES `Bank` (`BankId`), CONSTRAINT `Payment_ibfk_65` FOREIGN KEY (`PaymentStatusId`) REFERENCES `PaymentStatus` (`PaymentStatusId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 PACK_KEYS=0 COMMENT='Cadastro de Parcelas'; -- -- Dumping data for table `Payment` -- /*!40000 ALTER TABLE `Payment` DISABLE KEYS */; LOCK TABLES `Payment` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Payment` ENABLE KEYS */; -- -- Table structure for table `PaymentAccount` -- DROP TABLE IF EXISTS `PaymentAccount`; CREATE TABLE `PaymentAccount` ( `PaymentAccountId` smallint(5) unsigned NOT NULL auto_increment, `CustomerId` mediumint(8) unsigned NOT NULL default '0', `BankId` smallint(3) unsigned NOT NULL default '0', `Agency` varchar(5) NOT NULL default '', `Account` varchar(8) NOT NULL default '', `Name` varchar(40) NOT NULL default '', `IsActive` enum('True','False') NOT NULL default 'True', PRIMARY KEY (`PaymentAccountId`), KEY `CustomerId` (`CustomerId`), KEY `IsActive` (`IsActive`), KEY `BankId` (`BankId`), CONSTRAINT `PaymentAccount_ibfk_1` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`), CONSTRAINT `PaymentAccount_ibfk_2` FOREIGN KEY (`BankId`) REFERENCES `Bank` (`BankId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Contas bancárias de um referido Customer'; -- -- Dumping data for table `PaymentAccount` -- /*!40000 ALTER TABLE `PaymentAccount` DISABLE KEYS */; LOCK TABLES `PaymentAccount` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `PaymentAccount` ENABLE KEYS */; -- -- Table structure for table `PaymentStatus` -- DROP TABLE IF EXISTS `PaymentStatus`; CREATE TABLE `PaymentStatus` ( `PaymentStatusId` tinyint(3) NOT NULL auto_increment, `PaymentStatusOrder` tinyint(3) unsigned NOT NULL default '0', `PaymentStatus` varchar(30) NOT NULL default '', `Description` varchar(255) default NULL, PRIMARY KEY (`PaymentStatusId`), UNIQUE KEY `UniquePosition` (`PaymentStatusOrder`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Lista de Status de Pagamentos'; -- -- Dumping data for table `PaymentStatus` -- /*!40000 ALTER TABLE `PaymentStatus` DISABLE KEYS */; LOCK TABLES `PaymentStatus` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `PaymentStatus` ENABLE KEYS */; -- -- Table structure for table `PaymentType` -- DROP TABLE IF EXISTS `PaymentType`; CREATE TABLE `PaymentType` ( `PaymentTypeId` tinyint(3) unsigned NOT NULL auto_increment, `PaymentTypeOrder` tinyint(3) unsigned NOT NULL default '0', `PaymentTypeName` varchar(30) NOT NULL default '', PRIMARY KEY (`PaymentTypeId`), UNIQUE KEY `UniquePosition` (`PaymentTypeOrder`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Tipos de Pagamento'; -- -- Dumping data for table `PaymentType` -- /*!40000 ALTER TABLE `PaymentType` DISABLE KEYS */; LOCK TABLES `PaymentType` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `PaymentType` ENABLE KEYS */; -- -- Table structure for table `Person` -- DROP TABLE IF EXISTS `Person`; CREATE TABLE `Person` ( `CustomerId` mediumint(8) unsigned NOT NULL default '0', `Name` varchar(50) NOT NULL default '', `CurrentJobTitle` varchar(60) default NULL, `DateBirth` date NOT NULL default '0000-00-00', `Gender` enum('M','F') NOT NULL default 'M', `NationalityId` smallint(5) unsigned NOT NULL default '0', `MaritalStatus` enum('C','D','S','V') default NULL, `IsActive` enum('True','False') NOT NULL default 'True', UNIQUE KEY `CustomerId` (`CustomerId`), KEY `Name` (`Name`,`Gender`,`NationalityId`), CONSTRAINT `Person_ibfk_1` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `Person` -- /*!40000 ALTER TABLE `Person` DISABLE KEYS */; LOCK TABLES `Person` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Person` ENABLE KEYS */; -- -- Table structure for table `PhoneNumber` -- DROP TABLE IF EXISTS `PhoneNumber`; CREATE TABLE `PhoneNumber` ( `PhoneNumberId` int(11) unsigned NOT NULL auto_increment, `CustomerId` mediumint(8) unsigned NOT NULL default '0', `AreaCode` varchar(3) default NULL, `Number` varchar(10) NOT NULL default '', `Extension` varchar(3) default NULL, `TYPE` enum('Res','Com','Cel','Bip','Fax','Rec') default 'Res', `AskFor` varchar(20) default NULL, `Preferential` enum('True','False') NOT NULL default 'False', PRIMARY KEY (`PhoneNumberId`), KEY `CustomerID` (`CustomerId`), CONSTRAINT `PhoneNumber_ibfk_1` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Telefones de Customers'; -- -- Dumping data for table `PhoneNumber` -- /*!40000 ALTER TABLE `PhoneNumber` DISABLE KEYS */; LOCK TABLES `PhoneNumber` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `PhoneNumber` ENABLE KEYS */; -- -- Table structure for table `Product` -- DROP TABLE IF EXISTS `Product`; CREATE TABLE `Product` ( `ProductId` tinyint(3) unsigned NOT NULL auto_increment, `ParentProductId` tinyint(3) unsigned default NULL, `ProductGroupId` tinyint(3) unsigned default NULL, `Name` varchar(60) NOT NULL default '', `Description` varchar(255) default NULL, `RequiredCustomerTypes` set('B','R','P') NOT NULL default 'P', `InterfaceType` enum('Container','Placement','RecruitSelect') default NULL, `ProductParameters` text, PRIMARY KEY (`ProductId`), KEY `InterfaceType` (`InterfaceType`), KEY `ParentProductID` (`ParentProductId`), KEY `ProductGroupId` (`ProductGroupId`), CONSTRAINT `Product_ibfk_1` FOREIGN KEY (`ParentProductId`) REFERENCES `Product` (`ProductId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Listagem de Produtos'; -- -- Dumping data for table `Product` -- /*!40000 ALTER TABLE `Product` DISABLE KEYS */; LOCK TABLES `Product` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Product` ENABLE KEYS */; -- -- Table structure for table `ProductGroup` -- DROP TABLE IF EXISTS `ProductGroup`; CREATE TABLE `ProductGroup` ( `ProductGroupId` tinyint(3) unsigned NOT NULL auto_increment, `GroupName` varchar(50) NOT NULL default '', `CreatorId` mediumint(8) unsigned NOT NULL default '0', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`ProductGroupId`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `ProductGroup` -- /*!40000 ALTER TABLE `ProductGroup` DISABLE KEYS */; LOCK TABLES `ProductGroup` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `ProductGroup` ENABLE KEYS */; -- -- Table structure for table `ProductInspection` -- DROP TABLE IF EXISTS `ProductInspection`; CREATE TABLE `ProductInspection` ( `ProductId` tinyint(3) unsigned NOT NULL default '0', `InspectionTypeId` smallint(4) unsigned NOT NULL default '0', `IsActive` enum('True','False') NOT NULL default 'True', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', `CreatorId` mediumint(8) unsigned NOT NULL default '0', UNIQUE KEY `ProductId` (`ProductId`,`InspectionTypeId`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `ProductInspection` -- /*!40000 ALTER TABLE `ProductInspection` DISABLE KEYS */; LOCK TABLES `ProductInspection` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `ProductInspection` ENABLE KEYS */; -- -- Table structure for table `ProductSale` -- DROP TABLE IF EXISTS `ProductSale`; CREATE TABLE `ProductSale` ( `ProductSaleId` mediumint(8) unsigned NOT NULL auto_increment, `OpportunityId` mediumint(8) unsigned NOT NULL default '0', `ParentProductSaleId` mediumint(8) unsigned default NULL, `ProductId` tinyint(3) unsigned NOT NULL default '0', `Title` varchar(120) NOT NULL default '', `Price` decimal(7,2) default '00000.00', `NumberPayments` tinyint(3) unsigned default '0', `IsFree` enum('True','False') NOT NULL default 'False', `DateContracted` date NOT NULL default '0000-00-00', `DateDeadline` date default NULL, `ProductSaleStatusId` smallint(5) unsigned NOT NULL default '0', `IsConfidential` enum('True','False') NOT NULL default 'False', `Description` text, `InspectionStatusId` tinyint(2) unsigned NOT NULL default '0', `CreatorId` mediumint(8) NOT NULL default '0', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`ProductSaleId`), KEY `ProductSaleStatusIs` (`ProductSaleStatusId`), KEY `ProductId` (`ProductId`), KEY `InspectionStatus` (`InspectionStatusId`), KEY `OpportunityId` (`OpportunityId`), KEY `DateContracted` (`DateContracted`), KEY `ParentProductSaleId` (`ParentProductSaleId`), CONSTRAINT `ProductSale_ibfk_3` FOREIGN KEY (`ParentProductSaleId`) REFERENCES `ProductSale` (`ProductSaleId`), CONSTRAINT `ProductSale_ibfk_4` FOREIGN KEY (`ProductId`) REFERENCES `Product` (`ProductId`), CONSTRAINT `ProductSale_ibfk_5` FOREIGN KEY (`ProductSaleStatusId`) REFERENCES `ProductStatus` (`ProductStatusId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 PACK_KEYS=0 COMMENT='Tabela responsável pelos contratos do sistema.'; -- -- Dumping data for table `ProductSale` -- /*!40000 ALTER TABLE `ProductSale` DISABLE KEYS */; LOCK TABLES `ProductSale` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `ProductSale` ENABLE KEYS */; -- -- Table structure for table `ProductSaleConsultant` -- DROP TABLE IF EXISTS `ProductSaleConsultant`; CREATE TABLE `ProductSaleConsultant` ( `ProductSaleId` mediumint(8) unsigned NOT NULL default '0', `CustomerId` mediumint(8) unsigned NOT NULL default '0', `DateStart` datetime NOT NULL default '0000-00-00 00:00:00', `DateEnd` datetime default NULL, `IsActive` enum('True','False') NOT NULL default 'True', `CreatorId` mediumint(8) unsigned NOT NULL default '0', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`ProductSaleId`,`CustomerId`), KEY `ProductSaleId` (`ProductSaleId`), KEY `CustomerId` (`CustomerId`), CONSTRAINT `ProductSaleConsultant_ibfk_3` FOREIGN KEY (`ProductSaleId`) REFERENCES `ProductSale` (`ProductSaleId`), CONSTRAINT `ProductSaleConsultant_ibfk_4` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Consultores que cuidam de uma venda'; -- -- Dumping data for table `ProductSaleConsultant` -- /*!40000 ALTER TABLE `ProductSaleConsultant` DISABLE KEYS */; LOCK TABLES `ProductSaleConsultant` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `ProductSaleConsultant` ENABLE KEYS */; -- -- Table structure for table `ProductSaleCustomer` -- DROP TABLE IF EXISTS `ProductSaleCustomer`; CREATE TABLE `ProductSaleCustomer` ( `ProductSaleId` mediumint(8) unsigned NOT NULL default '0', `CustomerId` mediumint(8) unsigned NOT NULL default '0', `CreatorId` mediumint(8) NOT NULL default '0', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', UNIQUE KEY `DistinctProductSaleCustomer` (`ProductSaleId`,`CustomerId`), KEY `ProductSaleId` (`ProductSaleId`), KEY `CustomerId` (`CustomerId`), CONSTRAINT `ProductSaleCustomer_ibfk_3` FOREIGN KEY (`ProductSaleId`) REFERENCES `ProductSale` (`ProductSaleId`), CONSTRAINT `ProductSaleCustomer_ibfk_4` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `ProductSaleCustomer` -- /*!40000 ALTER TABLE `ProductSaleCustomer` DISABLE KEYS */; LOCK TABLES `ProductSaleCustomer` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `ProductSaleCustomer` ENABLE KEYS */; -- -- Table structure for table `ProductSaleInspectionLog` -- DROP TABLE IF EXISTS `ProductSaleInspectionLog`; CREATE TABLE `ProductSaleInspectionLog` ( `ProductSaleId` mediumint(8) unsigned NOT NULL default '0', `InspectionTypeId` smallint(4) unsigned NOT NULL default '0', `InspectionTypeStatusId` smallint(4) unsigned NOT NULL default '0', `Description` varchar(255) NOT NULL default '', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', `CreatorId` mediumint(8) unsigned NOT NULL default '0', KEY `ProductSaleId` (`ProductSaleId`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `ProductSaleInspectionLog` -- /*!40000 ALTER TABLE `ProductSaleInspectionLog` DISABLE KEYS */; LOCK TABLES `ProductSaleInspectionLog` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `ProductSaleInspectionLog` ENABLE KEYS */; -- -- Table structure for table `ProductSaleParameter` -- DROP TABLE IF EXISTS `ProductSaleParameter`; CREATE TABLE `ProductSaleParameter` ( `ProductSaleId` mediumint(8) unsigned NOT NULL default '0', `FieldName` varchar(30) NOT NULL default '', `FieldValueChar` varchar(255) default NULL, `FieldValueInt` int(11) default NULL, `CreatorId` int(11) default NULL, `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`ProductSaleId`,`FieldName`), KEY `ProductSaleId` (`ProductSaleId`), KEY `ValueChar` (`ProductSaleId`,`FieldName`,`FieldValueChar`), KEY `ValueInt` (`ProductSaleId`,`FieldName`,`FieldValueInt`), CONSTRAINT `ProductSaleParameter_ibfk_1` FOREIGN KEY (`ProductSaleId`) REFERENCES `ProductSale` (`ProductSaleId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 PACK_KEYS=1 COMMENT='"Configurações" especiais a cada venda'; -- -- Dumping data for table `ProductSaleParameter` -- /*!40000 ALTER TABLE `ProductSaleParameter` DISABLE KEYS */; LOCK TABLES `ProductSaleParameter` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `ProductSaleParameter` ENABLE KEYS */; -- -- Table structure for table `ProductStatus` -- DROP TABLE IF EXISTS `ProductStatus`; CREATE TABLE `ProductStatus` ( `ProductStatusId` smallint(5) unsigned NOT NULL auto_increment, `ProductId` tinyint(3) unsigned NOT NULL default '0', `StatusOrder` tinyint(3) unsigned NOT NULL default '1', `ProductStatus` varchar(30) NOT NULL default '', `Description` varchar(120) NOT NULL default '', `IsActive` enum('True','False') NOT NULL default 'True', PRIMARY KEY (`ProductStatusId`), UNIQUE KEY `StatusOrder` (`ProductId`,`StatusOrder`), KEY `IsActive` (`IsActive`), CONSTRAINT `ProductStatus_ibfk_1` FOREIGN KEY (`ProductId`) REFERENCES `Product` (`ProductId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Status de Produtos'; -- -- Dumping data for table `ProductStatus` -- /*!40000 ALTER TABLE `ProductStatus` DISABLE KEYS */; LOCK TABLES `ProductStatus` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `ProductStatus` ENABLE KEYS */; -- -- Table structure for table `Relationship` -- DROP TABLE IF EXISTS `Relationship`; CREATE TABLE `Relationship` ( `CustomerId` mediumint(8) unsigned NOT NULL default '0', `Title` varchar(16) NOT NULL default '', `RelationshipTypeId` tinyint(3) unsigned NOT NULL default '0', `FirstCustomerId` mediumint(8) unsigned NOT NULL default '0', `SecondCustomerId` mediumint(8) unsigned NOT NULL default '0', `IsActive` enum('True','False') NOT NULL default 'True', `DateStart` datetime NOT NULL default '0000-00-00 00:00:00', `DateEnd` datetime default NULL, `CreatorId` mediumint(8) NOT NULL default '0', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', UNIQUE KEY `CustomerId` (`CustomerId`), UNIQUE KEY `DistinctRelation` (`FirstCustomerId`,`SecondCustomerId`), KEY `TypeFirst` (`RelationshipTypeId`,`FirstCustomerId`), KEY `TypeSecond` (`RelationshipTypeId`,`SecondCustomerId`), KEY `FirstCustomerId` (`FirstCustomerId`), KEY `SecondCustomerId` (`SecondCustomerId`), KEY `IsActive` (`IsActive`), CONSTRAINT `Relationship_ibfk_10` FOREIGN KEY (`SecondCustomerId`) REFERENCES `Customer` (`CustomerId`), CONSTRAINT `Relationship_ibfk_7` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`), CONSTRAINT `Relationship_ibfk_8` FOREIGN KEY (`RelationshipTypeId`) REFERENCES `RelationshipType` (`RelationshipTypeId`), CONSTRAINT `Relationship_ibfk_9` FOREIGN KEY (`FirstCustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Relacionamento entre Customers'; -- -- Dumping data for table `Relationship` -- /*!40000 ALTER TABLE `Relationship` DISABLE KEYS */; LOCK TABLES `Relationship` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Relationship` ENABLE KEYS */; -- -- Table structure for table `RelationshipType` -- DROP TABLE IF EXISTS `RelationshipType`; CREATE TABLE `RelationshipType` ( `RelationshipTypeId` tinyint(3) unsigned NOT NULL auto_increment, `Name` varchar(16) NOT NULL default '', `Description` tinytext, `FirstCustomerType` enum('P','B','R','G') NOT NULL default 'P', `SecondCustomerType` enum('P','B','R','G') NOT NULL default 'P', PRIMARY KEY (`RelationshipTypeId`), KEY `FirstCustomerType` (`FirstCustomerType`), KEY `SecondCustomerType` (`SecondCustomerType`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Tipos de Relacionamentos entre Customers'; -- -- Dumping data for table `RelationshipType` -- /*!40000 ALTER TABLE `RelationshipType` DISABLE KEYS */; LOCK TABLES `RelationshipType` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `RelationshipType` ENABLE KEYS */; -- -- Table structure for table `Security` -- DROP TABLE IF EXISTS `Security`; CREATE TABLE `Security` ( `CustomerId` mediumint(8) unsigned NOT NULL default '0', `ModuleId` int(10) unsigned NOT NULL default '0', `StateId` int(10) unsigned NOT NULL default '0', `SecurityParentId` int(10) unsigned NOT NULL default '0', `Permitted` enum('True','False') NOT NULL default 'True', `FullAccess` enum('True','False') NOT NULL default 'False', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', KEY `CustomerId` (`CustomerId`), CONSTRAINT `Security_ibfk_1` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `Security` -- /*!40000 ALTER TABLE `Security` DISABLE KEYS */; LOCK TABLES `Security` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Security` ENABLE KEYS */; -- -- Table structure for table `Session` -- DROP TABLE IF EXISTS `Session`; CREATE TABLE `Session` ( `CustomerId` mediumint(8) unsigned NOT NULL default '0', `SessionId` varchar(32) NOT NULL default '', `SessionDate` datetime NOT NULL default '0000-00-00 00:00:00', `SessionTicks` mediumint(8) unsigned NOT NULL default '0', `ConnectionIP` varchar(15) NOT NULL default '', `ProxyId` varchar(50) default NULL, `ClientIP` varchar(15) NOT NULL default '', `UserAgent` varchar(255) default NULL, `IsInteractive` enum('True','False') NOT NULL default 'True', `SessionData` text, `LastClick` datetime NOT NULL default '0000-00-00 00:00:00', `LastPing` datetime default NULL, UNIQUE KEY `SessionId` (`SessionId`), UNIQUE KEY `CustomerId` (`CustomerId`), KEY `LastPing` (`LastPing`), KEY `ConnectionIP` (`ConnectionIP`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=1 COMMENT='Controle de sessões ativas no sistema'; -- -- Dumping data for table `Session` -- /*!40000 ALTER TABLE `Session` DISABLE KEYS */; LOCK TABLES `Session` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Session` ENABLE KEYS */; -- -- Table structure for table `SystemHistory` -- DROP TABLE IF EXISTS `SystemHistory`; CREATE TABLE `SystemHistory` ( `TableName` varchar(30) NOT NULL default '', `PrimaryKey` int(11) NOT NULL default '0', `UserID` mediumint(8) unsigned NOT NULL default '0', `Date` datetime NOT NULL default '0000-00-00 00:00:00', `IP` varchar(15) NOT NULL default '', `Description` text NOT NULL, `SerializedData` text NOT NULL, KEY `TableName` (`TableName`), KEY `PrimaryKey` (`PrimaryKey`), KEY `QueryType` (`QueryType`), KEY `UserID` (`UserID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Histórico do Sistema'; -- -- Dumping data for table `SystemHistory` -- /*!40000 ALTER TABLE `SystemHistory` DISABLE KEYS */; LOCK TABLES `SystemHistory` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `SystemHistory` ENABLE KEYS */; -- -- Table structure for table `Tax` -- DROP TABLE IF EXISTS `Tax`; CREATE TABLE `Tax` ( `TaxId` int(11) NOT NULL auto_increment, `Name` varchar(50) NOT NULL default '', `Description` text NOT NULL, `CountryId` int(11) default NULL, `StateId` int(11) NOT NULL default '0', `CityId` int(11) NOT NULL default '0', PRIMARY KEY (`TaxId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Lista de taxas e suas respectivas descrições'; -- -- Dumping data for table `Tax` -- /*!40000 ALTER TABLE `Tax` DISABLE KEYS */; LOCK TABLES `Tax` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `Tax` ENABLE KEYS */; -- -- Table structure for table `TaxCurrent` -- DROP TABLE IF EXISTS `TaxCurrent`; CREATE TABLE `TaxCurrent` ( `TaxId` int(11) NOT NULL default '0', `TaxCurrentId` int(11) NOT NULL auto_increment, `Percentage` float NOT NULL default '0', `Min_Value` int(11) NOT NULL default '0', `Max_Value` int(11) NOT NULL default '0', `StartDate` datetime NOT NULL default '0000-00-00 00:00:00', `EndDate` datetime NOT NULL default '0000-00-00 00:00:00', `IsActive` enum('True','False') NOT NULL default 'True', PRIMARY KEY (`TaxCurrentId`), KEY `Value` (`Min_Value`,`Max_Value`), KEY `TaxesId` (`TaxId`), CONSTRAINT `TaxCurrent_ibfk_1` FOREIGN KEY (`TaxId`) REFERENCES `Tax` (`TaxId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Incidência attual das taxas'; -- -- Dumping data for table `TaxCurrent` -- /*!40000 ALTER TABLE `TaxCurrent` DISABLE KEYS */; LOCK TABLES `TaxCurrent` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `TaxCurrent` ENABLE KEYS */; -- -- Table structure for table `TaxCustomer` -- DROP TABLE IF EXISTS `TaxCustomer`; CREATE TABLE `TaxCustomer` ( `CustomerId` mediumint(8) unsigned NOT NULL default '0', `TaxId` int(11) NOT NULL default '0', KEY `CustomerId` (`CustomerId`), KEY `TaxId` (`TaxId`), CONSTRAINT `TaxCustomer_ibfk_1` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`), CONSTRAINT `TaxCustomer_ibfk_2` FOREIGN KEY (`TaxId`) REFERENCES `Tax` (`TaxId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Taxas que incidem em um Customer'; -- -- Dumping data for table `TaxCustomer` -- /*!40000 ALTER TABLE `TaxCustomer` DISABLE KEYS */; LOCK TABLES `TaxCustomer` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `TaxCustomer` ENABLE KEYS */; -- -- Table structure for table `TaxPayment` -- DROP TABLE IF EXISTS `TaxPayment`; CREATE TABLE `TaxPayment` ( `PaymentId` int(11) unsigned NOT NULL default '0', `TaxCurrentId` int(11) NOT NULL default '0', KEY `PaymentId` (`PaymentId`), KEY `TaxCurrentId` (`TaxCurrentId`), CONSTRAINT `TaxPayment_ibfk_2` FOREIGN KEY (`PaymentId`) REFERENCES `Payment` (`PaymentId`), CONSTRAINT `TaxPayment_ibfk_3` FOREIGN KEY (`TaxCurrentId`) REFERENCES `TaxCurrent` (`TaxCurrentId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Taxas que incidem em uma parcela'; -- -- Dumping data for table `TaxPayment` -- /*!40000 ALTER TABLE `TaxPayment` DISABLE KEYS */; LOCK TABLES `TaxPayment` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `TaxPayment` ENABLE KEYS */; -- -- Table structure for table `TaxProduct` -- DROP TABLE IF EXISTS `TaxProduct`; CREATE TABLE `TaxProduct` ( `ProductId` tinyint(3) unsigned NOT NULL default '0', `TaxId` int(11) NOT NULL default '0', KEY `ProductId` (`ProductId`), KEY `TaxId` (`TaxId`), CONSTRAINT `TaxProduct_ibfk_1` FOREIGN KEY (`ProductId`) REFERENCES `Product` (`ProductId`), CONSTRAINT `TaxProduct_ibfk_2` FOREIGN KEY (`TaxId`) REFERENCES `Tax` (`TaxId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Taxas que incidem em uma parcela'; -- -- Dumping data for table `TaxProduct` -- /*!40000 ALTER TABLE `TaxProduct` DISABLE KEYS */; LOCK TABLES `TaxProduct` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `TaxProduct` ENABLE KEYS */; -- -- Table structure for table `TaxProductSale` -- DROP TABLE IF EXISTS `TaxProductSale`; CREATE TABLE `TaxProductSale` ( `ProductSaleId` mediumint(8) unsigned NOT NULL default '0', `TaxCurrentId` int(11) NOT NULL default '0', KEY `PaymentId` (`ProductSaleId`), KEY `TaxCurrentId` (`TaxCurrentId`), CONSTRAINT `TaxProductSale_ibfk_1` FOREIGN KEY (`ProductSaleId`) REFERENCES `ProductSale` (`ProductSaleId`), CONSTRAINT `TaxProductSale_ibfk_2` FOREIGN KEY (`TaxCurrentId`) REFERENCES `TaxCurrent` (`TaxCurrentId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Taxas que incidem em uma parcela'; -- -- Dumping data for table `TaxProductSale` -- /*!40000 ALTER TABLE `TaxProductSale` DISABLE KEYS */; LOCK TABLES `TaxProductSale` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `TaxProductSale` ENABLE KEYS */; -- -- Table structure for table `User` -- DROP TABLE IF EXISTS `User`; CREATE TABLE `User` ( `CustomerId` mediumint(8) unsigned NOT NULL default '0', `Login` char(30) NOT NULL default '', `Password` char(32) NOT NULL default '', UNIQUE KEY `Login` (`Login`), UNIQUE KEY `CustomerId` (`CustomerId`), CONSTRAINT `User_ibfk_1` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Customers que possuem acesso ao sistema'; -- -- Dumping data for table `User` -- /*!40000 ALTER TABLE `User` DISABLE KEYS */; LOCK TABLES `User` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `User` ENABLE KEYS */; -- -- Table structure for table `WebSite` -- DROP TABLE IF EXISTS `WebSite`; CREATE TABLE `WebSite` ( `WebSiteId` int(11) unsigned NOT NULL auto_increment, `CustomerId` mediumint(8) unsigned NOT NULL default '0', `WebSite` varchar(50) NOT NULL default '', `IsActive` enum('True','False') NOT NULL default 'True', `CreatorId` mediumint(8) NOT NULL default '0', `DateCreated` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`WebSiteId`), KEY `CustomerId` (`CustomerId`), CONSTRAINT `WebSite_ibfk_1` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='WebSite de Customers'; -- -- Dumping data for table `WebSite` -- /*!40000 ALTER TABLE `WebSite` DISABLE KEYS */; LOCK TABLES `WebSite` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `WebSite` ENABLE KEYS */; -- -- Table structure for table `WorkFlowActivity` -- DROP TABLE IF EXISTS `WorkFlowActivity`; CREATE TABLE `WorkFlowActivity` ( `ActivityId` mediumint(8) unsigned NOT NULL default '0', `ActivityModelId` mediumint(8) unsigned NOT NULL default '0', `ProcessId` mediumint(8) unsigned NOT NULL default '0', `ActivityDescription` text, `ActivityStatus` enum('O','W','C') default NULL, `ScheduleStartDate` datetime default NULL, `ScheduleEndDate` datetime default NULL, `PreviewStartDate` datetime default NULL, `PreviewEndDate` datetime default NULL, `StartDate` datetime default NULL, `EndDate` datetime default NULL, PRIMARY KEY (`ActivityId`), KEY `ActivityModelId` (`ActivityModelId`), KEY `ProcessId` (`ProcessId`), CONSTRAINT `WorkFlowActivity_ibfk_4` FOREIGN KEY (`ActivityModelId`) REFERENCES `WorkFlowActivityModel` (`ActivityModelId`), CONSTRAINT `WorkFlowActivity_ibfk_5` FOREIGN KEY (`ProcessId`) REFERENCES `WorkFlowProcess` (`ProcessId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Atividaes de um Processo'; -- -- Dumping data for table `WorkFlowActivity` -- /*!40000 ALTER TABLE `WorkFlowActivity` DISABLE KEYS */; LOCK TABLES `WorkFlowActivity` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `WorkFlowActivity` ENABLE KEYS */; -- -- Table structure for table `WorkFlowActivityModel` -- DROP TABLE IF EXISTS `WorkFlowActivityModel`; CREATE TABLE `WorkFlowActivityModel` ( `ActivityModelId` mediumint(8) unsigned NOT NULL default '0', `ProcessModelId` mediumint(8) unsigned NOT NULL default '0', `LogicalOperator` enum('OR','AND','XOR') default NULL, `ActivityModel` varchar(255) default NULL, PRIMARY KEY (`ActivityModelId`), KEY `ProcessModelId` (`ProcessModelId`), CONSTRAINT `WorkFlowActivityModel_ibfk_1` FOREIGN KEY (`ProcessModelId`) REFERENCES `WorkFlowProcessModel` (`ProcessModelId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `WorkFlowActivityModel` -- /*!40000 ALTER TABLE `WorkFlowActivityModel` DISABLE KEYS */; LOCK TABLES `WorkFlowActivityModel` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `WorkFlowActivityModel` ENABLE KEYS */; -- -- Table structure for table `WorkFlowActivityUser` -- DROP TABLE IF EXISTS `WorkFlowActivityUser`; CREATE TABLE `WorkFlowActivityUser` ( `ActivityId` mediumint(8) unsigned NOT NULL default '0', `CustomerId` mediumint(8) unsigned NOT NULL default '0', PRIMARY KEY (`ActivityId`,`CustomerId`), KEY `CustomerId` (`CustomerId`), CONSTRAINT `WorkFlowActivityUser_ibfk_1` FOREIGN KEY (`ActivityId`) REFERENCES `WorkFlowActivity` (`ActivityId`), CONSTRAINT `WorkFlowActivityUser_ibfk_2` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Usuários responsáveis por uma atividade'; -- -- Dumping data for table `WorkFlowActivityUser` -- /*!40000 ALTER TABLE `WorkFlowActivityUser` DISABLE KEYS */; LOCK TABLES `WorkFlowActivityUser` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `WorkFlowActivityUser` ENABLE KEYS */; -- -- Table structure for table `WorkFlowEventModel` -- DROP TABLE IF EXISTS `WorkFlowEventModel`; CREATE TABLE `WorkFlowEventModel` ( `EventModelId` int(11) NOT NULL default '0', `ActivityModelId` mediumint(8) unsigned NOT NULL default '0', `NextActivityModelId` mediumint(8) unsigned NOT NULL default '0', `EventDescription` text, `EventRanking` int(11) NOT NULL default '0', `EventType` enum('StartPoint','DecisionPoint','ClosingPoint') default NULL, PRIMARY KEY (`EventModelId`), KEY `ActivityModelId` (`ActivityModelId`), KEY `NextActivityModelId` (`NextActivityModelId`), CONSTRAINT `WorkFlowEventModel_ibfk_1` FOREIGN KEY (`ActivityModelId`) REFERENCES `WorkFlowActivity` (`ActivityModelId`), CONSTRAINT `WorkFlowEventModel_ibfk_2` FOREIGN KEY (`NextActivityModelId`) REFERENCES `WorkFlowActivity` (`ActivityModelId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `WorkFlowEventModel` -- /*!40000 ALTER TABLE `WorkFlowEventModel` DISABLE KEYS */; LOCK TABLES `WorkFlowEventModel` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `WorkFlowEventModel` ENABLE KEYS */; -- -- Table structure for table `WorkFlowProcess` -- DROP TABLE IF EXISTS `WorkFlowProcess`; CREATE TABLE `WorkFlowProcess` ( `ProcessId` mediumint(8) unsigned NOT NULL default '0', `ProcessModelId` mediumint(8) unsigned NOT NULL default '0', `CustomerGroupId` mediumint(8) unsigned NOT NULL default '0', `ProjectId` mediumint(8) unsigned NOT NULL default '0', `ProcessStatus` enum('O','W','C') default NULL, `ProcessName` varchar(255) default NULL, `ProcessDescription` text, `StartDate` datetime default NULL, `EndDate` datetime default NULL, PRIMARY KEY (`ProcessId`), KEY `ProcessModelId` (`ProcessModelId`), KEY `CustomerGroupId` (`CustomerGroupId`), KEY `ProjectId` (`ProjectId`), CONSTRAINT `WorkFlowProcess_ibfk_6` FOREIGN KEY (`ProcessModelId`) REFERENCES `WorkFlowProcessModel` (`ProcessModelId`), CONSTRAINT `WorkFlowProcess_ibfk_7` FOREIGN KEY (`CustomerGroupId`) REFERENCES `Group` (`CustomerId`), CONSTRAINT `WorkFlowProcess_ibfk_8` FOREIGN KEY (`ProjectId`) REFERENCES `WorkFlowProject` (`ProjectId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Cadastro de Processos '; -- -- Dumping data for table `WorkFlowProcess` -- /*!40000 ALTER TABLE `WorkFlowProcess` DISABLE KEYS */; LOCK TABLES `WorkFlowProcess` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `WorkFlowProcess` ENABLE KEYS */; -- -- Table structure for table `WorkFlowProcessModel` -- DROP TABLE IF EXISTS `WorkFlowProcessModel`; CREATE TABLE `WorkFlowProcessModel` ( `ProcessModelId` mediumint(8) unsigned NOT NULL default '0', `ProcessModel` varchar(255) default NULL, PRIMARY KEY (`ProcessModelId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `WorkFlowProcessModel` -- /*!40000 ALTER TABLE `WorkFlowProcessModel` DISABLE KEYS */; LOCK TABLES `WorkFlowProcessModel` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `WorkFlowProcessModel` ENABLE KEYS */; -- -- Table structure for table `WorkFlowProject` -- DROP TABLE IF EXISTS `WorkFlowProject`; CREATE TABLE `WorkFlowProject` ( `ProjectId` mediumint(8) unsigned NOT NULL default '0', `CustomerId` mediumint(8) unsigned NOT NULL default '0', `ProjectName` varchar(255) default NULL, `ProjectDescription` text, PRIMARY KEY (`ProjectId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `WorkFlowProject` -- /*!40000 ALTER TABLE `WorkFlowProject` DISABLE KEYS */; LOCK TABLES `WorkFlowProject` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `WorkFlowProject` ENABLE KEYS */; -- -- Table structure for table `WorkFlowTask` -- DROP TABLE IF EXISTS `WorkFlowTask`; CREATE TABLE `WorkFlowTask` ( `TaskId` mediumint(8) unsigned NOT NULL default '0', `ActivityId` mediumint(8) unsigned NOT NULL default '0', `TaskName` varchar(255) default NULL, `TaskDescription` text, `TaskStatus` enum('W','S','C') default NULL, `ScheduleStartDate` datetime default NULL, `ScheduleEndDate` datetime default NULL, `PreviewStartDate` datetime default NULL, `PreviewEndDate` datetime default NULL, `StartDate` datetime default NULL, `EndDate` datetime default NULL, PRIMARY KEY (`TaskId`), KEY `ActivityId` (`ActivityId`), CONSTRAINT `WorkFlowTask_ibfk_1` FOREIGN KEY (`ActivityId`) REFERENCES `WorkFlowActivity` (`ActivityId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Tarefas de uma atividade específica'; -- -- Dumping data for table `WorkFlowTask` -- /*!40000 ALTER TABLE `WorkFlowTask` DISABLE KEYS */; LOCK TABLES `WorkFlowTask` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `WorkFlowTask` ENABLE KEYS */; -- -- Table structure for table `WorkFlowTaskUser` -- DROP TABLE IF EXISTS `WorkFlowTaskUser`; CREATE TABLE `WorkFlowTaskUser` ( `TaskId` mediumint(8) unsigned NOT NULL default '0', `CustomerId` mediumint(8) unsigned NOT NULL default '0', PRIMARY KEY (`TaskId`,`CustomerId`), KEY `CustomerId` (`CustomerId`), CONSTRAINT `WorkFlowTaskUser_ibfk_1` FOREIGN KEY (`TaskId`) REFERENCES `WorkFlowTask` (`TaskId`), CONSTRAINT `WorkFlowTaskUser_ibfk_2` FOREIGN KEY (`CustomerId`) REFERENCES `Customer` (`CustomerId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Usuários responsáveis por uma tarefa'; -- -- Dumping data for table `WorkFlowTaskUser` -- /*!40000 ALTER TABLE `WorkFlowTaskUser` DISABLE KEYS */; LOCK TABLES `WorkFlowTaskUser` WRITE; UNLOCK TABLES; /*!40000 ALTER TABLE `WorkFlowTaskUser` ENABLE KEYS */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;