# ---------------------------------------------------------------------- #
# Script generated with: DeZign for Databases v6.2.0                     #
# Target DBMS:           MySQL 5                                         #
# Project file:          abliaDbComuni3.dez                              #
# Project name:          DB COMUNI - ABLIA                               #
# Author:                Andrea Colzi                                    #
# Script type:           Database creation script                        #
# Created on:            2011-03-01 17:25                                #
# ---------------------------------------------------------------------- #


# ---------------------------------------------------------------------- #
# Tables                                                                 #
# ---------------------------------------------------------------------- #

# ---------------------------------------------------------------------- #
# Add table "TIPO_BANNER"                                                #
# ---------------------------------------------------------------------- #

CREATE TABLE `TIPO_BANNER` (
    `id_tipoBanner` INTEGER NOT NULL AUTO_INCREMENT,
    `descrizione` VARCHAR(60),
    `larghezza` INTEGER,
    `altezza` INTEGER,
    `lastUpdTmst` TIMESTAMP,
    `lastUpdId_user` INTEGER,
    CONSTRAINT `PK_TIPO_BANNER` PRIMARY KEY (`id_tipoBanner`)
) ;

# ---------------------------------------------------------------------- #
# Add table "BANNER_STATS"                                               #
# ---------------------------------------------------------------------- #

CREATE TABLE `BANNER_STATS` (
    `id_bannerStats` INTEGER NOT NULL AUTO_INCREMENT,
    `id_banner` INTEGER,
    `entryPoint` VARCHAR(254) ,
    `ipAddress` varchar(40) ,
    `dataTimestamp` TIMESTAMP,
    `flgI_CT` INTEGER,
    `lastUpdId_user` INTEGER,
    `lastUpdTmst` TIMESTAMP,
    CONSTRAINT `PK_BANNER_STATS` PRIMARY KEY (`id_bannerStats`)
);

CREATE INDEX `IDX_BANNER_STATS_1` ON `BANNER_STATS` (`id_banner`);

# ---------------------------------------------------------------------- #
# Add table "BANNER"                                                     #
# ---------------------------------------------------------------------- #

CREATE TABLE `BANNER` (
    `id_banner` INTEGER NOT NULL AUTO_INCREMENT,
    `id_tipoBanner` INTEGER,
    `id_clifor` INTEGER,
	`descrizioneClifor` VARCHAR(254),
    `link` VARCHAR(254),
    `dataInizioCampagna` DATE,
    `dataFineCampagna` DATE,
    `flgAttivo` INTEGER,
    `impression` INTEGER,
    `clickThrough` INTEGER,
    `dataFineVld` DATE,
    `priorita` INTEGER ,
    `lastUpdTmst` TIMESTAMP,
    `lastUpdId_user` INTEGER,
    `titolo` VARCHAR(60),
    `descrizioneBanner` text,
    `imgTmst` CHAR(16),
    `flgTipo` INTEGER,
    CONSTRAINT `PK_BANNER` PRIMARY KEY (`id_banner`)
) ;

CREATE INDEX `IDX_BANNER_1` ON `BANNER` (`id_tipoBanner`);

# ---------------------------------------------------------------------- #
# Foreign key constraints                                                #
# ---------------------------------------------------------------------- #

ALTER TABLE `BANNER_STATS` ADD CONSTRAINT `BANNER_BANNER_STATS` 
    FOREIGN KEY (`id_banner`) REFERENCES `BANNER` (`id_banner`);

ALTER TABLE `BANNER` ADD CONSTRAINT `TIPO_BANNER_BANNER` 
    FOREIGN KEY (`id_tipoBanner`) REFERENCES `TIPO_BANNER` (`id_tipoBanner`);

ALTER TABLE `BANNER` ADD CONSTRAINT `CLIFOR_BANNER` 
    FOREIGN KEY (`id_clifor`) REFERENCES `CLIFOR` (`id_clifor`);



LOCK TABLES `TIPO_BANNER` WRITE;
/*!40000 ALTER TABLE `TIPO_BANNER` DISABLE KEYS */;
INSERT INTO `TIPO_BANNER` VALUES (1,'Rettangolo medio',320,250,'2011-03-04 12:40:11',1),(2,'Rettangolo Grandi',336,280,'2011-03-04 12:40:25',1),(3,'Leaderboard',720,90,'2011-03-04 12:40:45',1),(4,'Skyscraper largo',160,600,'2011-03-04 12:41:03',1),(5,'Banner',468,60,'2011-03-04 12:41:19',1),(6,'Mezzo Banner',234,60,'2011-03-04 12:41:30',1),(7,'Skyscraper',120,600,'2011-03-04 12:41:47',1),(8,'Banner Verticale',120,240,'2011-03-04 12:41:58',1),(9,'Quadrato',250,250,'2011-03-04 12:42:09',1),(10,'Quadrato Piccolo',200,200,'2011-03-04 12:42:34',1),(11,'Rettangolo Piccolo',180,150,'2011-03-04 12:42:49',1),(12,'Pulsante',125,125,'2011-03-04 12:43:06',1),(13,'Link grande',728,15,'2011-03-04 12:43:24',1),(14,'Link piccolo',468,15,'2011-03-04 12:43:48',1);
/*!40000 ALTER TABLE `TIPO_BANNER` ENABLE KEYS */;
UNLOCK TABLES;
