28 lines
958 B
SQL

-- Table: country_codes
CREATE TABLE `country_codes` (
`iso_3166_alpha2` CHAR(2) NOT NULL,
`LastUpdated` `LastUpdated` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`iso_3166_alpha2`)
) ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_unicode_ci;
-- Table: country_networks
CREATE TABLE `country_networks` (
`ip_country` CHAR(2) NOT NULL,
`ip_network` VARCHAR(15) NOT NULL,
`ip_network_bitmask` INT UNSIGNED NOT NULL,
`LastUpdated` `LastUpdated` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (
`ip_country`,
`ip_network`,
`ip_network_bitmask`
),
CONSTRAINT `fk_country_networks_country_codes`
FOREIGN KEY (`ip_country`)
REFERENCES `country_codes` (`iso_3166_alpha2`)
ON UPDATE CASCADE
ON DELETE CASCADE
) ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_unicode_ci;