
drop database if exists arch;
create database arch;

use arch;

drop server if exists b1;
drop server if exists b2;
drop server if exists b3;





use arch;


--
-- Table structure for table `ARCHIVE`
--

CREATE TABLE `ARCHIVE` (
  `ID_EVENT` bigint(20) unsigned NOT NULL DEFAULT 0,
  `ID_OBJ` int(10) unsigned DEFAULT NULL,
  `TYPOBJ` char(1) DEFAULT NULL,
  `ID_ATTR` int(11) DEFAULT NULL,
  `ID_PROP` int(11) DEFAULT NULL,
  `TYPPROP` varchar(10) DEFAULT NULL,
  `TYPATTR` varchar(10) DEFAULT NULL,
  `VAL` varchar(100) DEFAULT NULL,
  `VALNUM` double DEFAULT NULL,
  `TIMEEVENT` datetime DEFAULT NULL,
  `SOURCE` varchar(100) DEFAULT NULL,
  `ID_MESS` int(11) DEFAULT NULL,
  `TYPMESS` char(1) DEFAULT NULL,
  `SEVERITY` char(1) DEFAULT NULL,
  `DISP` varchar(20) DEFAULT NULL,
  `OWNER` varchar(20) DEFAULT NULL,
  `TYP_VAL` char(1) DEFAULT NULL,
  `ID_PACK` bigint(20) DEFAULT NULL,
  `TIMEUNIT` datetime DEFAULT NULL,
  `ARCH` char(1) DEFAULT NULL,
  `S_DISP` varchar(20) DEFAULT NULL,
   ID_UNIQ int(10) unsigned AUTO_INCREMENT,
  KEY `idx_timeevent` (`TIMEEVENT`),
  KEY `idx_idpack` (`ID_PACK`),
  KEY `idx_idobjtimeunit` (`ID_OBJ`,`TIMEUNIT`, ID_UNIQ),
  KEY  idx_uniq (ID_UNIQ)
) ENGINE=spider charset=utf8 COMMENT='wrapper "mysql", table "ARCHIVE"'
 PARTITION by HASH(ID_OBJ)
(
 partition b1 COMMENT='srv "b1"',
 partition b2 COMMENT='srv "b2"',
 partition b3 COMMENT='srv "b3"'
);


--
-- Table structure for table `POLOHY`
--

CREATE TABLE `POSITIONS` (
  `ID_PACK` bigint(20) DEFAULT NULL,
  `ID_OBJ` int(10) unsigned DEFAULT NULL,
  `TIMEEVENT` datetime DEFAULT NULL,
  `TIMEUNIT` datetime DEFAULT NULL,
  `LO` double DEFAULT NULL,
  `LA` double DEFAULT NULL,
  `VE` float DEFAULT NULL,
  `GPS` tinyint(1) DEFAULT NULL,
  `CR` smallint(2) DEFAULT NULL,
  `ARCH` char(1) DEFAULT NULL,
  `ID_ACTION` int(11) DEFAULT NULL,
   ID_UNIQ int(10) unsigned AUTO_INCREMENT,
  PRIMARY KEY `idx_idobjtimeunit` (`ID_OBJ`,`TIMEUNIT`, ID_UNIQ),
  KEY `idx_timeevent` (`TIMEEVENT`),
  KEY  idx_uniq (ID_UNIQ)
) ENGINE=spider charset=utf8 COMMENT='wrapper "mysql", table "POSITIONS"'
 PARTITION by HASH(ID_OBJ)
(
 partition b1 COMMENT='srv "b1"',
 partition b2 COMMENT='srv "b2"',
 partition b3 COMMENT='srv "b3"'
);
