-- MySQL Script generated by MySQL Workbench
-- 20/11/2019 00:00:00
-- Model: New Model    Version: 1.5.0
-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

-- -----------------------------------------------------
-- Schema rdap
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema rdap
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `rdap` DEFAULT CHARACTER SET utf8 ;
USE `rdap` ;

-- -----------------------------------------------------
-- Table `rdap`.`entity`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`entity` ;

CREATE TABLE IF NOT EXISTS `rdap`.`entity` (
  `ent_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Entity\'s unique id',
  `ent_handle` VARCHAR(100) NULL COMMENT 'A RIR/DNR unique identifier of the entity registration',
  `ent_port43` VARCHAR(254) NULL COMMENT 'A string containing the fully qualified host name or IP address of the WHOIS server where the entity instance may be found',
  PRIMARY KEY (`ent_id`),
  UNIQUE INDEX `id_UNIQUE` (`ent_id` ASC),
  UNIQUE INDEX `handle_UNIQUE` (`ent_handle` ASC))
ENGINE = InnoDB
COMMENT = 'This table contains the information of organizations, corporations, governments, non-profits, clubs, individual persons, and informal groups of people.';


-- -----------------------------------------------------
-- Table `rdap`.`vcard`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`vcard` ;

CREATE TABLE IF NOT EXISTS `rdap`.`vcard` (
  `vca_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Vcard\'s id',
  `vca_name` VARCHAR(100) NULL COMMENT 'Contact\'s name',
  `vca_company_name` VARCHAR(255) NULL COMMENT 'Contact\'s company name',
  `vca_company_url` VARCHAR(255) NULL COMMENT 'Contact\'s url',
  `vca_email` VARCHAR(200) NULL COMMENT 'Contact\'s email',
  `vca_voice` VARCHAR(50) NULL COMMENT 'Contact\'s telephone',
  `vca_cellphone` VARCHAR(50) NULL COMMENT 'Contact\'s cellphone',
  `vca_fax` VARCHAR(50) NULL COMMENT 'Contact\'s fax',
  `vca_job_title` VARCHAR(200) NULL COMMENT 'Contact\'s job title',
  PRIMARY KEY (`vca_id`),
  UNIQUE INDEX `vca_id_UNIQUE` (`vca_id` ASC))
ENGINE = InnoDB
COMMENT = 'This table contains the entities VCards.';


-- -----------------------------------------------------
-- Table `rdap`.`vcard_contact_uri`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`vcard_contact_uri` ;

CREATE TABLE IF NOT EXISTS `rdap`.`vcard_contact_uri` (
  `vcu_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Contact URI\'s id',
  `vca_id` BIGINT NOT NULL COMMENT 'Vcard\'s id',
  `vcu_order` INT UNSIGNED NOT NULL COMMENT 'Order of contact',
  `vcu_uri` VARCHAR(255) NOT NULL COMMENT 'Contact URI',
  PRIMARY KEY (`vcu_id`, `vca_id`),
  INDEX `fk_vcard_contact_uri_vcard1_idx` (`vca_id` ASC),
  CONSTRAINT `fk_vcard_contact_uri_1`
    FOREIGN KEY (`vca_id`)
    REFERENCES `rdap`.`vcard` (`vca_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the VCard Contact URI information.';


-- -----------------------------------------------------
-- Table `rdap`.`remark`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`remark` ;

CREATE TABLE IF NOT EXISTS `rdap`.`remark` (
  `rem_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Remark\'s id',
  `rem_title` VARCHAR(255) NULL COMMENT 'Remark\'s title',
  `rem_type` VARCHAR(255) NULL COMMENT 'Remark\'s type',
  `rem_lang` VARCHAR(255) NULL COMMENT 'Remark\'s language',
  PRIMARY KEY (`rem_id`),
  UNIQUE INDEX `rem_id_UNIQUE` (`rem_id` ASC))
ENGINE = InnoDB
COMMENT = 'This table contains the information about the Remarks that denote information about an object.';


-- -----------------------------------------------------
-- Table `rdap`.`link`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`link` ;

CREATE TABLE IF NOT EXISTS `rdap`.`link` (
  `lin_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Link\'s id',
  `lin_value` VARCHAR(45) NULL COMMENT 'Link\'s value',
  `lin_rel` VARCHAR(45) NULL COMMENT 'Link\'s rel attribute',
  `lin_href` VARCHAR(45) NOT NULL COMMENT 'Link\'s href attribute',
  `lin_title` VARCHAR(45) NULL COMMENT 'Link\'s title',
  `lin_media` VARCHAR(45) NULL COMMENT 'Link\'s media attribute',
  `lin_type` VARCHAR(45) NULL COMMENT 'Link\'s type',
  PRIMARY KEY (`lin_id`),
  UNIQUE INDEX `lin_id_UNIQUE` (`lin_id` ASC))
ENGINE = InnoDB
COMMENT = 'This table contains the information about links.';


-- -----------------------------------------------------
-- Table `rdap`.`event_action`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`event_action` ;

CREATE TABLE IF NOT EXISTS `rdap`.`event_action` (
  `eac_id` SMALLINT NOT NULL COMMENT 'Event action\'s id',
  `eac_name` VARCHAR(100) NULL COMMENT 'Event action\'s name',
  PRIMARY KEY (`eac_id`),
  UNIQUE INDEX `eac_id_UNIQUE` (`eac_id` ASC))
ENGINE = InnoDB
COMMENT = 'This table contains the catalog of Events Actions.';


-- -----------------------------------------------------
-- Table `rdap`.`event`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`event` ;

CREATE TABLE IF NOT EXISTS `rdap`.`event` (
  `eve_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Event\'s id',
  `eac_id` SMALLINT NOT NULL COMMENT 'Event action\'s id',
  `eve_actor` VARCHAR(45) NULL COMMENT 'Event actor',
  `eve_date` DATETIME NULL COMMENT 'Event date',
  PRIMARY KEY (`eve_id`),
  UNIQUE INDEX `eve_id_UNIQUE` (`eve_id` ASC),
  INDEX `fk_event_event_action1_idx` (`eac_id` ASC),
  CONSTRAINT `fk_event_event_action1`
    FOREIGN KEY (`eac_id`)
    REFERENCES `rdap`.`event_action` (`eac_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the information about events that have occurred on an object instance.';


-- -----------------------------------------------------
-- Table `rdap`.`roles`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`roles` ;

CREATE TABLE IF NOT EXISTS `rdap`.`roles` (
  `rol_id` TINYINT NOT NULL COMMENT 'Role\'s id',
  `rol_name` VARCHAR(100) NULL COMMENT 'Role\'s name',
  PRIMARY KEY (`rol_id`))
ENGINE = InnoDB
COMMENT = 'This table contains the catalog of Roles that an entity could have.';


-- -----------------------------------------------------
-- Table `rdap`.`zone`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`zone` ;

CREATE TABLE IF NOT EXISTS `rdap`.`zone` (
  `zone_id` SMALLINT NOT NULL AUTO_INCREMENT COMMENT 'Zone\'s id',
  `zone_name` VARCHAR(254) NOT NULL COMMENT 'Zone\'s name',
  PRIMARY KEY (`zone_id`),
  UNIQUE INDEX `ZONE_ID_UNIQUE` (`zone_id` ASC),
  UNIQUE INDEX `zone_name_UNIQUE` (`zone_name` ASC))
ENGINE = InnoDB
COMMENT = 'This table contains the zones managed by the RDAP server owner.';


-- -----------------------------------------------------
-- Table `rdap`.`domain`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`domain` ;

CREATE TABLE IF NOT EXISTS `rdap`.`domain` (
  `dom_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Domain\'s unique id',
  `dom_handle` VARCHAR(255) NULL COMMENT 'A RIR/DNR unique identifier of the domain registration',
  `dom_unicode_name` VARCHAR(255) NULL COMMENT 'A string containing a domain name in Unicode' COLLATE utf8_bin,
  `dom_port43` VARCHAR(254) NULL COMMENT 'A string containing the fully qualified host name or IP address of the WHOIS server where the domain instance may be found',
  `zone_id` SMALLINT NOT NULL COMMENT 'Zone\'s id',
  PRIMARY KEY (`dom_id`, `zone_id`),
  INDEX `fk_DOMAIN_ZONE1_idx` (`zone_id` ASC),
  UNIQUE INDEX `dom_id_UNIQUE` (`dom_id` ASC),
  UNIQUE INDEX `dom_handle_UNIQUE` (`dom_handle` ASC),
  CONSTRAINT `fk_DOMAIN_ZONE1`
    FOREIGN KEY (`zone_id`)
    REFERENCES `rdap`.`zone` (`zone_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the information about the domain registration.';



-- -----------------------------------------------------
-- Table `rdap`.`domain_entity_roles`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`domain_entity_roles` ;

CREATE TABLE IF NOT EXISTS `rdap`.`domain_entity_roles` (
  `dom_id` BIGINT NOT NULL COMMENT 'Domain\'s id',
  `ent_id` BIGINT NOT NULL COMMENT 'Entity\'s id',
  `rol_id` TINYINT NOT NULL COMMENT 'Role\'s id',
  PRIMARY KEY (`dom_id`, `ent_id`, `rol_id`),
  INDEX `fk_entity_roles_roles1_idx` (`rol_id` ASC),
  INDEX `fk_entity_roles_entity1_idx` (`ent_id` ASC),
  INDEX `fk_domain_entity_roles_domain1_idx` (`dom_id` ASC),
  UNIQUE INDEX `ux_domain_role_unique` (`dom_id` ASC, `rol_id` ASC),
  CONSTRAINT `fk_entity_roles_roles1`
    FOREIGN KEY (`rol_id`)
    REFERENCES `rdap`.`roles` (`rol_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_entity_roles_entity1`
    FOREIGN KEY (`ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_domain_entity_roles_domain1`
    FOREIGN KEY (`dom_id`)
    REFERENCES `rdap`.`domain` (`dom_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the role that an Entity has in relation to a Domain.';


-- -----------------------------------------------------
-- Table `rdap`.`remark_description`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`remark_description` ;

CREATE TABLE IF NOT EXISTS `rdap`.`remark_description` (
  `rde_order` MEDIUMINT NOT NULL COMMENT 'Placement of the description at the Remark',
  `rem_id` BIGINT NOT NULL COMMENT 'Remark\'s id',
  `rde_description` VARCHAR(255) NOT NULL COMMENT 'Remark\'s description',
  PRIMARY KEY (`rde_order`, `rem_id`),
  CONSTRAINT `fk_REMARK_DESCRIPTION_REMARK1`
    FOREIGN KEY (`rem_id`)
    REFERENCES `rdap`.`remark` (`rem_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `rdap`.`entity_remarks`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`entity_remarks` ;

CREATE TABLE IF NOT EXISTS `rdap`.`entity_remarks` (
  `ent_id` BIGINT NOT NULL COMMENT 'Entity\'s id',
  `rem_id` BIGINT NOT NULL COMMENT 'Remark\'s id',
  PRIMARY KEY (`ent_id`, `rem_id`),
  INDEX `fk_entity_remarks_remark1_idx` (`rem_id` ASC),
  UNIQUE INDEX `rem_id_UNIQUE` (`rem_id` ASC),
  CONSTRAINT `fk_ENTITY_REMARKS_ENTITY1`
    FOREIGN KEY (`ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_entity_remarks_remark1`
    FOREIGN KEY (`rem_id`)
    REFERENCES `rdap`.`remark` (`rem_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an Entity and its remarks.';


-- -----------------------------------------------------
-- Table `rdap`.`status`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`status` ;

CREATE TABLE IF NOT EXISTS `rdap`.`status` (
  `sta_id` SMALLINT NOT NULL COMMENT 'Status\'s id',
  `sta_name` VARCHAR(100) NULL COMMENT 'Status\'s name.',
  PRIMARY KEY (`sta_id`),
  UNIQUE INDEX `sta_id_UNIQUE` (`sta_id` ASC))
ENGINE = InnoDB
COMMENT = 'This table contains the Status catalog.';


-- -----------------------------------------------------
-- Table `rdap`.`entity_status`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`entity_status` ;

CREATE TABLE IF NOT EXISTS `rdap`.`entity_status` (
  `ent_id` BIGINT NOT NULL COMMENT 'Entity\'s id',
  `sta_id` SMALLINT NOT NULL COMMENT 'Status\'s id',
  PRIMARY KEY (`ent_id`, `sta_id`),
  INDEX `fk_entity_status_status1_idx` (`sta_id` ASC),
  INDEX `fk_entity_status_entity1_idx` (`ent_id` ASC),
  CONSTRAINT `fk_entity_status_status1`
    FOREIGN KEY (`sta_id`)
    REFERENCES `rdap`.`status` (`sta_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_entity_status_entity1`
    FOREIGN KEY (`ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an Entity and its status.';


-- -----------------------------------------------------
-- Table `rdap`.`entity_events`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`entity_events` ;

CREATE TABLE IF NOT EXISTS `rdap`.`entity_events` (
  `ent_id` BIGINT NOT NULL COMMENT 'Entity\'s id',
  `eve_id` BIGINT NOT NULL COMMENT 'Event\'s id',
  PRIMARY KEY (`ent_id`, `eve_id`),
  INDEX `fk_entity_events_event1_idx` (`eve_id` ASC),
  UNIQUE INDEX `eve_id_UNIQUE` (`eve_id` ASC),
  CONSTRAINT `fk_ENTITY_EVENT_ENTITY1`
    FOREIGN KEY (`ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_entity_events_event1`
    FOREIGN KEY (`eve_id`)
    REFERENCES `rdap`.`event` (`eve_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an Entity and its events.';


-- -----------------------------------------------------
-- Table `rdap`.`entity_links`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`entity_links` ;

CREATE TABLE IF NOT EXISTS `rdap`.`entity_links` (
  `ent_id` BIGINT NOT NULL COMMENT 'Entity\'s id',
  `lin_id` BIGINT NOT NULL COMMENT 'Link\'s id',
  PRIMARY KEY (`ent_id`, `lin_id`),
  INDEX `fk_entity_links_link1_idx` (`lin_id` ASC),
  UNIQUE INDEX `lin_id_UNIQUE` (`lin_id` ASC),
  CONSTRAINT `fk_ENTITY_LINK_ENTITY1`
    FOREIGN KEY (`ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_entity_links_link1`
    FOREIGN KEY (`lin_id`)
    REFERENCES `rdap`.`link` (`lin_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an Entity and its links.';


-- -----------------------------------------------------
-- Table `rdap`.`country_code`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`country_code` ;

CREATE TABLE IF NOT EXISTS `rdap`.`country_code` (
  `ccd_id` SMALLINT UNSIGNED NOT NULL COMMENT 'Country code\'s id',
  `ccd_code` VARCHAR(2) NOT NULL COMMENT 'The two-character country code',
  PRIMARY KEY (`ccd_id`),
  UNIQUE INDEX `ccd_id_UNIQUE` (`ccd_id` ASC))
ENGINE = InnoDB
COMMENT = 'This table contains the catalog of the two-character country code.\n';


-- -----------------------------------------------------
-- Table `rdap`.`autonomous_system_number`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`autonomous_system_number` ;

CREATE TABLE IF NOT EXISTS `rdap`.`autonomous_system_number` (
  `asn_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'ASN\'s unique id',
  `asn_handle` VARCHAR(100) NOT NULL COMMENT 'A RIR unique identifier of the autnum registration',
  `asn_start_autnum` BIGINT NOT NULL COMMENT 'A number representing the starting number in the block of Autonomous System numbers',
  `asn_end_autnum` BIGINT NOT NULL COMMENT 'A number representing the ending number in the block of Autonomous System numbers',
  `asn_name` VARCHAR(200) NULL DEFAULT NULL COMMENT 'An identifier assigned to the autnum registration by the registration holder',
  `asn_type` VARCHAR(200) NULL DEFAULT NULL COMMENT 'A string containing a RIR specific classification of the autnum',
  `asn_port43` VARCHAR(254) NULL DEFAULT NULL COMMENT 'A string containing the fully qualified host name or IP addres of the WHOIS server where the ASN instance may be found',
  `ccd_id` SMALLINT UNSIGNED NOT NULL COMMENT 'Country code id',
  PRIMARY KEY (`asn_id`, `ccd_id`),
  UNIQUE INDEX `asn_handle_UNIQUE` (`asn_handle` ASC),
  UNIQUE INDEX `asn_id_UNIQUE` (`asn_id` ASC),
  INDEX `fk_autonomous_system_number_country_code1_idx` (`ccd_id` ASC),
  CONSTRAINT `fk_autonomous_system_number_country_code1`
    FOREIGN KEY (`ccd_id`)
    REFERENCES `rdap`.`country_code` (`ccd_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the information of the Autonomous system numbers (ASN).\n';


-- -----------------------------------------------------
-- Table `rdap`.`asn_entity_roles`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`asn_entity_roles` ;

CREATE TABLE IF NOT EXISTS `rdap`.`asn_entity_roles` (
  `asn_id` BIGINT NOT NULL COMMENT 'ASN\'s id',
  `ent_id` BIGINT NOT NULL COMMENT 'Entity\'s id',
  `rol_id` TINYINT NOT NULL COMMENT 'Role\'s id',
  PRIMARY KEY (`asn_id`, `ent_id`, `rol_id`),
  INDEX `fk_ENTITY_AUTNUMS_autonomous_system_number1_idx` (`asn_id` ASC),
  INDEX `fk_asn_entity_roles_roles1_idx` (`rol_id` ASC),
  CONSTRAINT `fk_ENTITY_AUTNUMS_ENTITY1`
    FOREIGN KEY (`ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_ENTITY_AUTNUMS_autonomous_system_number1`
    FOREIGN KEY (`asn_id`)
    REFERENCES `rdap`.`autonomous_system_number` (`asn_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_asn_entity_roles_roles1`
    FOREIGN KEY (`rol_id`)
    REFERENCES `rdap`.`roles` (`rol_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the role that an Entity has in relation to an ASN.\n';


-- -----------------------------------------------------
-- Table `rdap`.`nameserver`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`nameserver` ;

CREATE TABLE IF NOT EXISTS `rdap`.`nameserver` (
  `nse_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Nameserver\'s id',
  `nse_handle` VARCHAR(100) NULL COMMENT 'A RIR/DNR unique identifier of the nameserver registration',
  `nse_unicode_name` VARCHAR(255) NULL COMMENT 'A string containing a nameserver name in Unicode' COLLATE utf8_bin,
  `nse_port43` VARCHAR(254) NULL DEFAULT NULL COMMENT 'A string containing the fully qualified host name or IP address of the WHOIS server where the nameserver instance may be found',
  PRIMARY KEY (`nse_id`),
  UNIQUE INDEX `nse_handle_UNIQUE` (`nse_handle` ASC),
  UNIQUE INDEX `nse_id_UNIQUE` (`nse_id` ASC))
ENGINE = InnoDB
COMMENT = 'This table contains information regarding DNS nameservers used in both forward and reverse DNS.';



-- -----------------------------------------------------
-- Table `rdap`.`domain_nameservers`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`domain_nameservers` ;

CREATE TABLE IF NOT EXISTS `rdap`.`domain_nameservers` (
  `dom_id` BIGINT NOT NULL COMMENT 'Domain\'s id',
  `nse_id` BIGINT NOT NULL COMMENT 'Nameserver\'s id',
  PRIMARY KEY (`dom_id`, `nse_id`),
  INDEX `fk_DOMAIN_NAMESERVERS_nameserver1_idx` (`nse_id` ASC),
  CONSTRAINT `fk_DOMAIN_NAMESERVERS_DOMAIN1`
    FOREIGN KEY (`dom_id`)
    REFERENCES `rdap`.`domain` (`dom_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_DOMAIN_NAMESERVERS_nameserver1`
    FOREIGN KEY (`nse_id`)
    REFERENCES `rdap`.`nameserver` (`nse_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between a Domain and its nameservers.';


-- -----------------------------------------------------
-- Table `rdap`.`secure_dns`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`secure_dns` ;

CREATE TABLE IF NOT EXISTS `rdap`.`secure_dns` (
  `sdns_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Secure dns\'s id',
  `sdns_zone_signed` TINYINT(1) NOT NULL COMMENT 'Flag to show if the zone has been signed (1=true, 0=false)',
  `sdns_delegation_signed` TINYINT(1) NOT NULL COMMENT 'Flag to show if there are DS records in the parent (1=true, 0=false)',
  `sdns_max_sig_life` INT NULL COMMENT 'An integer representing the signature lifetime in seconds to be used when creating the RRSIG DS record in the parent zone',
  `dom_id` BIGINT NOT NULL COMMENT 'Domain\'s id',
  PRIMARY KEY (`sdns_id`),
  INDEX `fk_SECURE_DNS_DOMAIN1_idx` (`dom_id` ASC),
  UNIQUE INDEX `sdns_id_UNIQUE` (`sdns_id` ASC),
  CONSTRAINT `fk_SECURE_DNS_DOMAIN1`
    FOREIGN KEY (`dom_id`)
    REFERENCES `rdap`.`domain` (`dom_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the information about a domain Secure DNS.';


-- -----------------------------------------------------
-- Table `rdap`.`ds_data`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`ds_data` ;

CREATE TABLE IF NOT EXISTS `rdap`.`ds_data` (
  `dsd_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Ds data\'s id',
  `sdns_id` BIGINT NOT NULL COMMENT 'Secure DNS\'s id',
  `dsd_keytag` INT NOT NULL COMMENT 'An integer as specified by the key tag field of a DNS DS record',
  `dsd_algorithm` INT NOT NULL COMMENT 'An integer as specified by the algorithm field of a DNS DS record',
  `dsd_digest` VARCHAR(255) NOT NULL COMMENT 'A string as specified by the digest field of a DNS DS record',
  `dsd_digest_type` INT NOT NULL COMMENT 'An integer as specified by the digest type field of a DNS DS record',
  PRIMARY KEY (`dsd_id`, `sdns_id`),
  INDEX `fk_ds_data_secure_dns1_idx` (`sdns_id` ASC),
  UNIQUE INDEX `dsd_id_UNIQUE` (`dsd_id` ASC),
  CONSTRAINT `fk_ds_data_secure_dns1`
    FOREIGN KEY (`sdns_id`)
    REFERENCES `rdap`.`secure_dns` (`sdns_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the information of a secure DNS DS record.';


-- -----------------------------------------------------
-- Table `rdap`.`domain_status`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`domain_status` ;

CREATE TABLE IF NOT EXISTS `rdap`.`domain_status` (
  `dom_id` BIGINT NOT NULL COMMENT 'Domain\'s id',
  `sta_id` SMALLINT NOT NULL COMMENT 'Status\'s id',
  PRIMARY KEY (`dom_id`, `sta_id`),
  INDEX `fk_domain_status_status1_idx` (`sta_id` ASC),
  CONSTRAINT `fk_DOMAIN_STATUS_DOMAIN1`
    FOREIGN KEY (`dom_id`)
    REFERENCES `rdap`.`domain` (`dom_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_domain_status_status1`
    FOREIGN KEY (`sta_id`)
    REFERENCES `rdap`.`status` (`sta_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between a Domain and its status.';


-- -----------------------------------------------------
-- Table `rdap`.`domain_remarks`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`domain_remarks` ;

CREATE TABLE IF NOT EXISTS `rdap`.`domain_remarks` (
  `dom_id` BIGINT NOT NULL COMMENT 'Domain\'s id',
  `rem_id` BIGINT NOT NULL COMMENT 'Remark\'s id',
  PRIMARY KEY (`dom_id`, `rem_id`),
  INDEX `fk_domain_remarks_remark1_idx` (`rem_id` ASC),
  UNIQUE INDEX `rem_id_UNIQUE` (`rem_id` ASC),
  CONSTRAINT `fk_DOMAIN_REMARKS_DOMAIN1`
    FOREIGN KEY (`dom_id`)
    REFERENCES `rdap`.`domain` (`dom_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_domain_remarks_remark1`
    FOREIGN KEY (`rem_id`)
    REFERENCES `rdap`.`remark` (`rem_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between a Domain and its remarks.';


-- -----------------------------------------------------
-- Table `rdap`.`domain_links`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`domain_links` ;

CREATE TABLE IF NOT EXISTS `rdap`.`domain_links` (
  `dom_id` BIGINT NOT NULL COMMENT 'Domain\'s id',
  `lin_id` BIGINT NOT NULL COMMENT 'Link\'s id',
  PRIMARY KEY (`dom_id`, `lin_id`),
  INDEX `fk_domain_links_link1_idx` (`lin_id` ASC),
  UNIQUE INDEX `lin_id_UNIQUE` (`lin_id` ASC),
  CONSTRAINT `fk_DOMAIN_LINKS_DOMAIN1`
    FOREIGN KEY (`dom_id`)
    REFERENCES `rdap`.`domain` (`dom_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_domain_links_link1`
    FOREIGN KEY (`lin_id`)
    REFERENCES `rdap`.`link` (`lin_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between a Domain and its links.\n';


-- -----------------------------------------------------
-- Table `rdap`.`domain_events`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`domain_events` ;

CREATE TABLE IF NOT EXISTS `rdap`.`domain_events` (
  `dom_id` BIGINT NOT NULL COMMENT 'Domain\'s id',
  `eve_id` BIGINT NOT NULL COMMENT 'Event\'s id',
  PRIMARY KEY (`dom_id`, `eve_id`),
  INDEX `fk_domain_events_event1_idx` (`eve_id` ASC),
  UNIQUE INDEX `eve_id_UNIQUE` (`eve_id` ASC),
  CONSTRAINT `fk_DOMAIN_EVENTS_DOMAIN1`
    FOREIGN KEY (`dom_id`)
    REFERENCES `rdap`.`domain` (`dom_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_domain_events_event1`
    FOREIGN KEY (`eve_id`)
    REFERENCES `rdap`.`event` (`eve_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between a Domain and its events.';


-- -----------------------------------------------------
-- Table `rdap`.`ip_version`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`ip_version` ;

CREATE TABLE IF NOT EXISTS `rdap`.`ip_version` (
  `ive_id` TINYINT UNSIGNED NOT NULL COMMENT 'IP version\'s id',
  `ive_name` VARCHAR(2) NOT NULL COMMENT 'IP version\'s name (\'v4\' or \'v6\')',
  PRIMARY KEY (`ive_id`),
  UNIQUE INDEX `ipv_name_UNIQUE` (`ive_name` ASC),
  UNIQUE INDEX `ipv_id_UNIQUE` (`ive_id` ASC))
ENGINE = InnoDB
COMMENT = 'This table contains the catalog of ip version types.';


-- -----------------------------------------------------
-- Table `rdap`.`ip_network`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`ip_network` ;

CREATE TABLE IF NOT EXISTS `rdap`.`ip_network` (
  `ine_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'IP network\'s id',
  `ine_handle` VARCHAR(255) NOT NULL COMMENT 'A RIR/DNR unique identifier of the IP network registration',
  `ine_start_address_up` BIGINT UNSIGNED NULL DEFAULT NULL COMMENT 'The up part of the starting IP address of the network',
  `ine_start_address_down` BIGINT UNSIGNED NOT NULL COMMENT 'The down part of the starting IP address of the network',
  `ine_end_address_up` BIGINT UNSIGNED NULL DEFAULT NULL COMMENT 'The up part of the ending IP address of the network',
  `ine_end_address_down` BIGINT UNSIGNED NOT NULL COMMENT 'The down part of the ending IP address of the network',
  `ine_name` VARCHAR(255) NULL DEFAULT NULL COMMENT 'An identifier assigned to the network registration by the registration holder',
  `ine_type` VARCHAR(255) NULL DEFAULT NULL COMMENT 'A string containing a RIR/DNR specific classification of the Network',
  `ine_port43` VARCHAR(254) NULL DEFAULT NULL COMMENT 'A string containing the fully qualified host name or IP address of the WHOIS server where the IP network instance may be found',
  `ccd_id` SMALLINT UNSIGNED NOT NULL COMMENT 'Country code\'s id',
  `ip_version_id` TINYINT UNSIGNED NOT NULL COMMENT 'IP version\'s id',
  `ine_parent_handle` VARCHAR(255) NULL COMMENT 'A string containing a RIR/DNR unique identifier of the parent network of this network registration',
  `ine_cidr` SMALLINT NULL COMMENT 'Network mask length of the IP address',
  PRIMARY KEY (`ine_id`, `ine_handle`),
  UNIQUE INDEX `ine_handle_UNIQUE` (`ine_handle` ASC),
  UNIQUE INDEX `ine_id_UNIQUE` (`ine_id` ASC),
  INDEX `fk_ip_network_country_code1_idx` (`ccd_id` ASC),
  INDEX `fk_ip_network_ip_version1_idx` (`ip_version_id` ASC),
  INDEX `ipv4_start_idx` USING BTREE (`ine_start_address_down` ASC),
  INDEX `ipv4_end_idx` USING BTREE (`ine_end_address_down` ASC),
  INDEX `ipv6_start_idx` USING BTREE (`ine_start_address_up` ASC, `ine_start_address_down` ASC),
  INDEX `ipv6_end_idx` USING BTREE (`ine_end_address_up` ASC, `ine_end_address_down` ASC),
  CONSTRAINT `fk_ip_network_country_code1`
    FOREIGN KEY (`ccd_id`)
    REFERENCES `rdap`.`country_code` (`ccd_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_ip_network_ip_version1`
    FOREIGN KEY (`ip_version_id`)
    REFERENCES `rdap`.`ip_version` (`ive_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the information about the network registration and entities related to an IP network.';


-- -----------------------------------------------------
-- Table `rdap`.`domain_networks`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`domain_networks` ;

CREATE TABLE IF NOT EXISTS `rdap`.`domain_networks` (
  `dom_id` BIGINT NOT NULL COMMENT 'Domain\'s id',
  `ine_id` BIGINT UNSIGNED NOT NULL COMMENT 'IP Network\'s id',
  PRIMARY KEY (`dom_id`, `ine_id`),
  INDEX `fk_DOMAIN_NETWORKS_ip_network1_idx` (`ine_id` ASC),
  CONSTRAINT `fk_DOMAIN_NETWORKS_DOMAIN1`
    FOREIGN KEY (`dom_id`)
    REFERENCES `rdap`.`domain` (`dom_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_DOMAIN_NETWORKS_ip_network1`
    FOREIGN KEY (`ine_id`)
    REFERENCES `rdap`.`ip_network` (`ine_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between a Domain and its ip networks.';


-- -----------------------------------------------------
-- Table `rdap`.`ds_events`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`ds_events` ;

CREATE TABLE IF NOT EXISTS `rdap`.`ds_events` (
  `dsd_id` BIGINT NOT NULL COMMENT 'Ds data\'s id',
  `eve_id` BIGINT NOT NULL COMMENT 'Event\'s id',
  PRIMARY KEY (`dsd_id`, `eve_id`),
  INDEX `fk_ds_events_event1_idx` (`eve_id` ASC),
  UNIQUE INDEX `event_eve_id_UNIQUE` (`eve_id` ASC),
  CONSTRAINT `fk_DS_EVENTS_DS_DATA1`
    FOREIGN KEY (`dsd_id`)
    REFERENCES `rdap`.`ds_data` (`dsd_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_ds_events_event1`
    FOREIGN KEY (`eve_id`)
    REFERENCES `rdap`.`event` (`eve_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between a DS Data and its events.';


-- -----------------------------------------------------
-- Table `rdap`.`ds_links`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`ds_links` ;

CREATE TABLE IF NOT EXISTS `rdap`.`ds_links` (
  `dsd_id` BIGINT NOT NULL COMMENT 'DS data\'s id',
  `lin_id` BIGINT NOT NULL COMMENT 'Link\'s id',
  PRIMARY KEY (`dsd_id`, `lin_id`),
  INDEX `fk_ds_links_link1_idx` (`lin_id` ASC),
  UNIQUE INDEX `lin_id_UNIQUE` (`lin_id` ASC),
  CONSTRAINT `fk_DS_LINKS_DS_DATA1`
    FOREIGN KEY (`dsd_id`)
    REFERENCES `rdap`.`ds_data` (`dsd_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_ds_links_link1`
    FOREIGN KEY (`lin_id`)
    REFERENCES `rdap`.`link` (`lin_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between a DS Data and its links.';


-- -----------------------------------------------------
-- Table `rdap`.`nameserver_status`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`nameserver_status` ;

CREATE TABLE IF NOT EXISTS `rdap`.`nameserver_status` (
  `nse_id` BIGINT NOT NULL COMMENT 'Nameserver\'s id',
  `sta_id` SMALLINT NOT NULL COMMENT 'Status\'s id',
  PRIMARY KEY (`nse_id`, `sta_id`),
  INDEX `fk_nameserver_status_status1_idx` (`sta_id` ASC),
  CONSTRAINT `fk_nameserver_status_nameserver`
    FOREIGN KEY (`nse_id`)
    REFERENCES `rdap`.`nameserver` (`nse_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_nameserver_status_status1`
    FOREIGN KEY (`sta_id`)
    REFERENCES `rdap`.`status` (`sta_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between a Nameserver and its status.';


-- -----------------------------------------------------
-- Table `rdap`.`ip_address`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`ip_address` ;

CREATE TABLE IF NOT EXISTS `rdap`.`ip_address` (
  `iad_id` INT NOT NULL AUTO_INCREMENT COMMENT 'IP address\'s id',
  `nse_id` BIGINT NOT NULL COMMENT 'Nameserver\'s id',
  `iad_type` TINYINT NOT NULL COMMENT 'IP address type (4 or 6)',
  `iad_value` VARBINARY(16) NOT NULL COMMENT 'IP address value',
  PRIMARY KEY (`iad_id`, `nse_id`),
  UNIQUE INDEX `iad_id_UNIQUE` (`iad_id` ASC),
  CONSTRAINT `fk_nameserver_ip_addresses_nameserver1`
    FOREIGN KEY (`nse_id`)
    REFERENCES `rdap`.`nameserver` (`nse_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the information of a nameserver\'s ip addresses.';


-- -----------------------------------------------------
-- Table `rdap`.`nameserver_remarks`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`nameserver_remarks` ;

CREATE TABLE IF NOT EXISTS `rdap`.`nameserver_remarks` (
  `nse_id` BIGINT NOT NULL COMMENT 'Nameserver\'s id',
  `rem_id` BIGINT NOT NULL COMMENT 'Remark\'s id',
  PRIMARY KEY (`nse_id`, `rem_id`),
  INDEX `fk_nameserver_remarks_remark1_idx` (`rem_id` ASC),
  UNIQUE INDEX `rem_id_UNIQUE` (`rem_id` ASC),
  CONSTRAINT `fk_nameserver_entities_nameserver10`
    FOREIGN KEY (`nse_id`)
    REFERENCES `rdap`.`nameserver` (`nse_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_nameserver_remarks_remark1`
    FOREIGN KEY (`rem_id`)
    REFERENCES `rdap`.`remark` (`rem_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between a Nameserver and its remarks.';


-- -----------------------------------------------------
-- Table `rdap`.`nameserver_links`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`nameserver_links` ;

CREATE TABLE IF NOT EXISTS `rdap`.`nameserver_links` (
  `nse_id` BIGINT NOT NULL COMMENT 'Nameserver\'s id',
  `lin_id` BIGINT NOT NULL COMMENT 'Link\'s id',
  PRIMARY KEY (`nse_id`, `lin_id`),
  INDEX `fk_nameserver_links_link1_idx` (`lin_id` ASC),
  UNIQUE INDEX `lin_id_UNIQUE` (`lin_id` ASC),
  CONSTRAINT `fk_nameserver_entities_nameserver100`
    FOREIGN KEY (`nse_id`)
    REFERENCES `rdap`.`nameserver` (`nse_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_nameserver_links_link1`
    FOREIGN KEY (`lin_id`)
    REFERENCES `rdap`.`link` (`lin_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between a Nameserver and its links.';


-- -----------------------------------------------------
-- Table `rdap`.`asn_status`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`asn_status` ;

CREATE TABLE IF NOT EXISTS `rdap`.`asn_status` (
  `asn_id` BIGINT NOT NULL COMMENT 'ASN\'s id',
  `sta_id` SMALLINT NOT NULL COMMENT 'Status\'s id',
  PRIMARY KEY (`asn_id`, `sta_id`),
  INDEX `fk_asn_status_status1_idx` (`sta_id` ASC),
  CONSTRAINT `fk_asn_status_autonomous_system_number1`
    FOREIGN KEY (`asn_id`)
    REFERENCES `rdap`.`autonomous_system_number` (`asn_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_asn_status_status1`
    FOREIGN KEY (`sta_id`)
    REFERENCES `rdap`.`status` (`sta_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an ASN and its status.\n';


-- -----------------------------------------------------
-- Table `rdap`.`asn_remarks`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`asn_remarks` ;

CREATE TABLE IF NOT EXISTS `rdap`.`asn_remarks` (
  `asn_id` BIGINT NOT NULL COMMENT 'ASN\'s id',
  `rem_id` BIGINT NOT NULL COMMENT 'Remark\'s id',
  PRIMARY KEY (`asn_id`, `rem_id`),
  INDEX `fk_asn_remarks_remark1_idx` (`rem_id` ASC),
  UNIQUE INDEX `rem_id_UNIQUE` (`rem_id` ASC),
  CONSTRAINT `fk_asn_status_autonomous_system_number10`
    FOREIGN KEY (`asn_id`)
    REFERENCES `rdap`.`autonomous_system_number` (`asn_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_asn_remarks_remark1`
    FOREIGN KEY (`rem_id`)
    REFERENCES `rdap`.`remark` (`rem_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an ASN and its remarks.\n';


-- -----------------------------------------------------
-- Table `rdap`.`asn_links`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`asn_links` ;

CREATE TABLE IF NOT EXISTS `rdap`.`asn_links` (
  `asn_id` BIGINT NOT NULL COMMENT 'ASN\'s id',
  `lin_id` BIGINT NOT NULL COMMENT 'Link\'s id',
  PRIMARY KEY (`asn_id`, `lin_id`),
  INDEX `fk_asn_links_link1_idx` (`lin_id` ASC),
  UNIQUE INDEX `lin_id_UNIQUE` (`lin_id` ASC),
  CONSTRAINT `fk_asn_status_autonomous_system_number12`
    FOREIGN KEY (`asn_id`)
    REFERENCES `rdap`.`autonomous_system_number` (`asn_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_asn_links_link1`
    FOREIGN KEY (`lin_id`)
    REFERENCES `rdap`.`link` (`lin_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an ASN and its links.\n';


-- -----------------------------------------------------
-- Table `rdap`.`asn_events`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`asn_events` ;

CREATE TABLE IF NOT EXISTS `rdap`.`asn_events` (
  `asn_id` BIGINT NOT NULL COMMENT 'ASN\'s id',
  `eve_id` BIGINT NOT NULL COMMENT 'Event\'s id',
  PRIMARY KEY (`asn_id`, `eve_id`),
  INDEX `fk_asn_events_event1_idx` (`eve_id` ASC),
  UNIQUE INDEX `eve_id_UNIQUE` (`eve_id` ASC),
  CONSTRAINT `fk_asn_status_autonomous_system_number120`
    FOREIGN KEY (`asn_id`)
    REFERENCES `rdap`.`autonomous_system_number` (`asn_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_asn_events_event1`
    FOREIGN KEY (`eve_id`)
    REFERENCES `rdap`.`event` (`eve_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an ASN and its events.\n';


-- -----------------------------------------------------
-- Table `rdap`.`ip_network_status`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`ip_network_status` ;

CREATE TABLE IF NOT EXISTS `rdap`.`ip_network_status` (
  `ine_id` BIGINT UNSIGNED NOT NULL COMMENT 'IP Network\'s id',
  `sta_id` SMALLINT NOT NULL COMMENT 'Status\'s id',
  PRIMARY KEY (`ine_id`, `sta_id`),
  INDEX `fk_ip_network_status_status1_idx` (`sta_id` ASC),
  CONSTRAINT `fk_ip_network_status_ip_network1`
    FOREIGN KEY (`ine_id`)
    REFERENCES `rdap`.`ip_network` (`ine_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_ip_network_status_status1`
    FOREIGN KEY (`sta_id`)
    REFERENCES `rdap`.`status` (`sta_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an IP Network and its status.';


-- -----------------------------------------------------
-- Table `rdap`.`ip_network_remarks`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`ip_network_remarks` ;

CREATE TABLE IF NOT EXISTS `rdap`.`ip_network_remarks` (
  `ine_id` BIGINT UNSIGNED NOT NULL COMMENT 'IP Network\'s id',
  `rem_id` BIGINT NOT NULL COMMENT 'Remark\'s id',
  PRIMARY KEY (`ine_id`, `rem_id`),
  INDEX `fk_ip_network_remarks_remark1_idx` (`rem_id` ASC),
  UNIQUE INDEX `remark_rem_id_UNIQUE` (`rem_id` ASC),
  CONSTRAINT `fk_ip_network_status_ip_network100`
    FOREIGN KEY (`ine_id`)
    REFERENCES `rdap`.`ip_network` (`ine_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_ip_network_remarks_remark1`
    FOREIGN KEY (`rem_id`)
    REFERENCES `rdap`.`remark` (`rem_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an IP Network and its remarks.';


-- -----------------------------------------------------
-- Table `rdap`.`ip_network_links`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`ip_network_links` ;

CREATE TABLE IF NOT EXISTS `rdap`.`ip_network_links` (
  `ine_id` BIGINT UNSIGNED NOT NULL COMMENT 'IP Network\'s id',
  `lin_id` BIGINT NOT NULL COMMENT 'Link\'s id',
  PRIMARY KEY (`ine_id`, `lin_id`),
  INDEX `fk_ip_network_links_link1_idx` (`lin_id` ASC),
  UNIQUE INDEX `lin_id_UNIQUE` (`lin_id` ASC),
  CONSTRAINT `fk_ip_network_status_ip_network101`
    FOREIGN KEY (`ine_id`)
    REFERENCES `rdap`.`ip_network` (`ine_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_ip_network_links_link1`
    FOREIGN KEY (`lin_id`)
    REFERENCES `rdap`.`link` (`lin_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an IP Network and its links.';


-- -----------------------------------------------------
-- Table `rdap`.`ip_network_events`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`ip_network_events` ;

CREATE TABLE IF NOT EXISTS `rdap`.`ip_network_events` (
  `ine_id` BIGINT UNSIGNED NOT NULL COMMENT 'IP Network\'s id',
  `eve_id` BIGINT NOT NULL COMMENT 'Event\'s id',
  PRIMARY KEY (`ine_id`, `eve_id`),
  INDEX `fk_ip_network_events_event1_idx` (`eve_id` ASC),
  UNIQUE INDEX `event_eve_id_UNIQUE` (`eve_id` ASC),
  CONSTRAINT `fk_ip_network_status_ip_network102`
    FOREIGN KEY (`ine_id`)
    REFERENCES `rdap`.`ip_network` (`ine_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_ip_network_events_event1`
    FOREIGN KEY (`eve_id`)
    REFERENCES `rdap`.`event` (`eve_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an IP Network and its events.';


-- -----------------------------------------------------
-- Table `rdap`.`variant`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`variant` ;

CREATE TABLE IF NOT EXISTS `rdap`.`variant` (
  `var_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Variant\'s id',
  `var_idn_table` VARCHAR(100) NULL COMMENT 'Variant\'s IDN table',
  `dom_id` BIGINT NOT NULL COMMENT 'Domain\'s id',
  PRIMARY KEY (`var_id`, `dom_id`),
  INDEX `fk_variant_domain1_idx` (`dom_id` ASC),
  UNIQUE INDEX `var_id_UNIQUE` (`var_id` ASC),
  CONSTRAINT `fk_variant_domain1`
    FOREIGN KEY (`dom_id`)
    REFERENCES `rdap`.`domain` (`dom_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains information about the domain\'s variants.';


-- -----------------------------------------------------
-- Table `rdap`.`relation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`relation` ;

CREATE TABLE IF NOT EXISTS `rdap`.`relation` (
  `rel_id` TINYINT NOT NULL COMMENT 'Relation\'s id',
  `rel_type` VARCHAR(255) NULL COMMENT 'Relation\'s type',
  PRIMARY KEY (`rel_id`),
  UNIQUE INDEX `rel_id_UNIQUE` (`rel_id` ASC))
ENGINE = InnoDB
COMMENT = 'This table contains the catalog of Variant relations.';


-- -----------------------------------------------------
-- Table `rdap`.`variant_name`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`variant_name` ;

CREATE TABLE IF NOT EXISTS `rdap`.`variant_name` (
  `var_id` BIGINT NOT NULL COMMENT 'Variant\'s id',
  `vna_unicode_name` VARCHAR(255) NOT NULL COMMENT 'Variant\'s unicode name' COLLATE utf8_bin,
  CONSTRAINT `fk_VARIANT_NAME_VARIANT1`
    FOREIGN KEY (`var_id`)
    REFERENCES `rdap`.`variant` (`var_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the variants names.';




-- -----------------------------------------------------
-- Table `rdap`.`vcard_postal_info`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`vcard_postal_info` ;

CREATE TABLE IF NOT EXISTS `rdap`.`vcard_postal_info` (
  `vpi_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Postal info\'s id',
  `vca_id` BIGINT NOT NULL COMMENT 'Vcard\'s id',
  `vpi_type` VARCHAR(45) NULL COMMENT 'Postal info\'s type.',
  `vpi_country` VARCHAR(100) NULL COMMENT 'Country',
  `vpi_country_code` VARCHAR(2) NULL COMMENT 'Country Code',
  `vpi_city` VARCHAR(100) NULL COMMENT 'City',
  `vpi_street1` VARCHAR(100) NULL COMMENT 'Street (first part)',
  `vpi_street2` VARCHAR(100) NULL COMMENT 'Street (second part)',
  `vpi_street3` VARCHAR(100) NULL COMMENT 'Street (third part)',
  `vpi_state` VARCHAR(100) NULL COMMENT 'State',
  `vpi_postal_code` VARCHAR(100) NULL COMMENT 'Postal code',
  PRIMARY KEY (`vpi_id`, `vca_id`),
  UNIQUE INDEX `vca_id_UNIQUE` (`vpi_id` ASC),
  INDEX `fk_vcard_postal_info_vcard1_idx` (`vca_id` ASC),
  CONSTRAINT `fk_vcard_postal_info_vcard1`
    FOREIGN KEY (`vca_id`)
    REFERENCES `rdap`.`vcard` (`vca_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the VCards postal information.';


-- -----------------------------------------------------
-- Table `rdap`.`nameserver_events`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`nameserver_events` ;

CREATE TABLE IF NOT EXISTS `rdap`.`nameserver_events` (
  `nse_id` BIGINT NOT NULL COMMENT 'Nameserver\'s id',
  `eve_id` BIGINT NOT NULL COMMENT 'Event\'s id',
  PRIMARY KEY (`nse_id`, `eve_id`),
  INDEX `fk_nameserver_events_event1_idx` (`eve_id` ASC),
  UNIQUE INDEX `eve_id_UNIQUE` (`eve_id` ASC),
  CONSTRAINT `fk_nameserver_events_nameserver1`
    FOREIGN KEY (`nse_id`)
    REFERENCES `rdap`.`nameserver` (`nse_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_nameserver_events_event1`
    FOREIGN KEY (`eve_id`)
    REFERENCES `rdap`.`event` (`eve_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between a Nameserver and its events.';


-- -----------------------------------------------------
-- Table `rdap`.`public_id`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`public_id` ;

CREATE TABLE IF NOT EXISTS `rdap`.`public_id` (
  `pid_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Public id\'s id',
  `pid_type` VARCHAR(255) NULL COMMENT 'Public id\'s type',
  `pid_identifier` VARCHAR(255) NULL COMMENT 'Public id\'s identifier',
  PRIMARY KEY (`pid_id`))
ENGINE = InnoDB
COMMENT = 'This table contains the information about Public IDs.';


-- -----------------------------------------------------
-- Table `rdap`.`domain_public_ids`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`domain_public_ids` ;

CREATE TABLE IF NOT EXISTS `rdap`.`domain_public_ids` (
  `dom_id` BIGINT NOT NULL COMMENT 'Domain\'s id',
  `pid_id` BIGINT NOT NULL COMMENT 'Public id\'s id',
  PRIMARY KEY (`dom_id`, `pid_id`),
  INDEX `fk_domain_public_ids_public_id1_idx` (`pid_id` ASC),
  UNIQUE INDEX `public_id_pid_id_UNIQUE` (`pid_id` ASC),
  CONSTRAINT `fk_domain_public_ids_domain1`
    FOREIGN KEY (`dom_id`)
    REFERENCES `rdap`.`domain` (`dom_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_domain_public_ids_public_id1`
    FOREIGN KEY (`pid_id`)
    REFERENCES `rdap`.`public_id` (`pid_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between a Domain and its public ids.';


-- -----------------------------------------------------
-- Table `rdap`.`entity_public_ids`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`entity_public_ids` ;

CREATE TABLE IF NOT EXISTS `rdap`.`entity_public_ids` (
  `ent_id` BIGINT NOT NULL COMMENT 'Entity\'s id',
  `pid_id` BIGINT NOT NULL COMMENT 'Public id\'s id',
  PRIMARY KEY (`ent_id`, `pid_id`),
  INDEX `fk_domain_public_ids_public_id1_idx` (`pid_id` ASC),
  UNIQUE INDEX `public_id_pid_id_UNIQUE` (`pid_id` ASC),
  INDEX `fk_domain_public_ids_copy2_entity1_idx` (`ent_id` ASC),
  CONSTRAINT `fk_domain_public_ids_public_id11`
    FOREIGN KEY (`pid_id`)
    REFERENCES `rdap`.`public_id` (`pid_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_domain_public_ids_copy2_entity1`
    FOREIGN KEY (`ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an Entity and its public ids.';


-- -----------------------------------------------------
-- Table `rdap`.`event_links`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`event_links` ;

CREATE TABLE IF NOT EXISTS `rdap`.`event_links` (
  `eve_id` BIGINT NOT NULL COMMENT 'Event\'s id',
  `lin_id` BIGINT NOT NULL COMMENT 'Link\'s id',
  PRIMARY KEY (`eve_id`, `lin_id`),
  INDEX `fk_event_has_link_link1_idx` (`lin_id` ASC),
  INDEX `fk_event_has_link_event1_idx` (`eve_id` ASC),
  CONSTRAINT `fk_event_has_link_event1`
    FOREIGN KEY (`eve_id`)
    REFERENCES `rdap`.`event` (`eve_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_event_has_link_link1`
    FOREIGN KEY (`lin_id`)
    REFERENCES `rdap`.`link` (`lin_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an Event and its links.';


-- -----------------------------------------------------
-- Table `rdap`.`remark_links`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`remark_links` ;

CREATE TABLE IF NOT EXISTS `rdap`.`remark_links` (
  `rem_id` BIGINT NOT NULL COMMENT 'Remark\'s id',
  `lin_id` BIGINT NOT NULL COMMENT 'Link\'s id',
  PRIMARY KEY (`rem_id`, `lin_id`),
  INDEX `fk_remark_has_link_link2_idx` (`lin_id` ASC),
  INDEX `fk_remark_has_link_remark2_idx` (`rem_id` ASC),
  CONSTRAINT `fk_remark_has_link_remark2`
    FOREIGN KEY (`rem_id`)
    REFERENCES `rdap`.`remark` (`rem_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_remark_has_link_link2`
    FOREIGN KEY (`lin_id`)
    REFERENCES `rdap`.`link` (`lin_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between a Remark and its links.';


-- -----------------------------------------------------
-- Table `rdap`.`variant_relation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`variant_relation` ;

CREATE TABLE IF NOT EXISTS `rdap`.`variant_relation` (
  `rel_id` TINYINT NOT NULL COMMENT 'Relation\'s id',
  `var_id` BIGINT NOT NULL COMMENT 'Variant\'s id',
  PRIMARY KEY (`rel_id`, `var_id`),
  INDEX `fk_relation_has_variant_variant1_idx` (`var_id` ASC),
  INDEX `fk_relation_has_variant_relation1_idx` (`rel_id` ASC),
  CONSTRAINT `fk_relation_has_variant_relation1`
    FOREIGN KEY (`rel_id`)
    REFERENCES `rdap`.`relation` (`rel_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_relation_has_variant_variant1`
    FOREIGN KEY (`var_id`)
    REFERENCES `rdap`.`variant` (`var_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the type of relations of a Variant.';


-- -----------------------------------------------------
-- Table `rdap`.`entity_contact`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`entity_contact` ;

CREATE TABLE IF NOT EXISTS `rdap`.`entity_contact` (
  `ent_id` BIGINT NOT NULL COMMENT 'Entity\'s id',
  `vca_id` BIGINT NOT NULL COMMENT 'Vcard\'s id',
  PRIMARY KEY (`ent_id`, `vca_id`),
  INDEX `fk_entity_contact_vcard1_idx` (`vca_id` ASC),
  CONSTRAINT `fk_entity_contact_entity1`
    FOREIGN KEY (`ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_entity_contact_vcard1`
    FOREIGN KEY (`vca_id`)
    REFERENCES `rdap`.`vcard` (`vca_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an Entity and its contact VCard.';


-- -----------------------------------------------------
-- Table `rdap`.`nameserver_entity_roles`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`nameserver_entity_roles` ;

CREATE TABLE IF NOT EXISTS `rdap`.`nameserver_entity_roles` (
  `nse_id` BIGINT NOT NULL COMMENT 'Nameserver\'s id',
  `ent_id` BIGINT NOT NULL COMMENT 'Entity\'s id',
  `rol_id` TINYINT NOT NULL COMMENT 'Role\'s id',
  PRIMARY KEY (`nse_id`, `ent_id`, `rol_id`),
  INDEX `fk_entity_roles_roles1_idx` (`rol_id` ASC),
  INDEX `fk_entity_roles_entity1_idx` (`ent_id` ASC),
  INDEX `fk_nameserver_entity_roles_nameserver1_idx` (`nse_id` ASC),
  CONSTRAINT `fk_entity_roles_roles10`
    FOREIGN KEY (`rol_id`)
    REFERENCES `rdap`.`roles` (`rol_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_entity_roles_entity10`
    FOREIGN KEY (`ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_nameserver_entity_roles_nameserver1`
    FOREIGN KEY (`nse_id`)
    REFERENCES `rdap`.`nameserver` (`nse_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the role that an Entity has in relation to a Nameserver.';


-- -----------------------------------------------------
-- Table `rdap`.`entity_entity_roles`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`entity_entity_roles` ;

CREATE TABLE IF NOT EXISTS `rdap`.`entity_entity_roles` (
  `main_ent_id` BIGINT NOT NULL COMMENT 'Main Entity\'s id',
  `ent_id` BIGINT NOT NULL COMMENT 'Entity\'s id',
  `rol_id` TINYINT NOT NULL COMMENT 'Role\'s id',
  PRIMARY KEY (`main_ent_id`, `ent_id`, `rol_id`),
  INDEX `fk_entity_roles_roles1_idx` (`rol_id` ASC),
  INDEX `fk_entity_roles_entity1_idx` (`ent_id` ASC),
  INDEX `fk_entity_entity_roles_entity1_idx` (`main_ent_id` ASC),
  CONSTRAINT `fk_entity_roles_roles100`
    FOREIGN KEY (`rol_id`)
    REFERENCES `rdap`.`roles` (`rol_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_entity_roles_entity100`
    FOREIGN KEY (`ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_entity_entity_roles_entity1`
    FOREIGN KEY (`main_ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the role that an Entity has in relation to another Entity.';


-- -----------------------------------------------------
-- Table `rdap`.`rdap_user`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`rdap_user` ;

CREATE TABLE IF NOT EXISTS `rdap`.`rdap_user` (
  `rus_name` VARCHAR(100) NOT NULL COMMENT 'User\'s name',
  `rus_pass` VARCHAR(200) NOT NULL COMMENT 'User\'s password',
  `rus_max_search_results` INT NULL COMMENT 'Max number of results that will be returned for the user',
  PRIMARY KEY (`rus_name`),
  INDEX `rus_name_index` (`rus_name` ASC))
ENGINE = InnoDB
COMMENT = 'This table contains the information about the users.';


-- -----------------------------------------------------
-- Table `rdap`.`rdap_access_role`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`rdap_access_role` ;

CREATE TABLE IF NOT EXISTS `rdap`.`rdap_access_role` (
  `rar_name` VARCHAR(45) NOT NULL COMMENT 'Access role\'s name',
  `rar_description` VARCHAR(250) NOT NULL COMMENT 'Access role\'s description',
  PRIMARY KEY (`rar_name`))
ENGINE = InnoDB
COMMENT = 'This table contains a catalog of the access roles that a user could have.';


-- -----------------------------------------------------
-- Table `rdap`.`rdap_user_role`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`rdap_user_role` ;

CREATE TABLE IF NOT EXISTS `rdap`.`rdap_user_role` (
  `rus_name` VARCHAR(100) NOT NULL COMMENT 'User\'s name',
  `rar_name` VARCHAR(45) NOT NULL COMMENT 'Access role\'s name',
  PRIMARY KEY (`rus_name`, `rar_name`),
  INDEX `rdap_access_role_ir_fk_idx` (`rar_name` ASC),
  CONSTRAINT `rdap_user_ir_fk`
    FOREIGN KEY (`rus_name`)
    REFERENCES `rdap`.`rdap_user` (`rus_name`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `rdap_access_role_ir_fk`
    FOREIGN KEY (`rar_name`)
    REFERENCES `rdap`.`rdap_access_role` (`rar_name`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the Access Roles that a User has.';


-- -----------------------------------------------------
-- Table `rdap`.`ip_network_entity_roles`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`ip_network_entity_roles` ;

CREATE TABLE IF NOT EXISTS `rdap`.`ip_network_entity_roles` (
  `ine_id` BIGINT UNSIGNED NOT NULL COMMENT 'IP Network\'s id',
  `ent_id` BIGINT NOT NULL COMMENT 'Entity\'s id',
  `rol_id` TINYINT NOT NULL COMMENT 'Role\'s id',
  PRIMARY KEY (`ine_id`, `ent_id`, `rol_id`),
  INDEX `fk_ipn_entity_roles_ip_network1_idx` (`ine_id` ASC),
  INDEX `fk_ipn_entity_roles_roles1_idx` (`rol_id` ASC),
  CONSTRAINT `fk_ipn_entity_roles_entity1`
    FOREIGN KEY (`ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_ipn_entity_roles_ip_network1`
    FOREIGN KEY (`ine_id`)
    REFERENCES `rdap`.`ip_network` (`ine_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_ipn_entity_roles_roles1`
    FOREIGN KEY (`rol_id`)
    REFERENCES `rdap`.`roles` (`rol_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the role that an Entity has in relation to an IP Network.';


-- -----------------------------------------------------
-- Table `rdap`.`ip_network_parent_relation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`ip_network_parent_relation` ;

CREATE TABLE IF NOT EXISTS `rdap`.`ip_network_parent_relation` (
  `ine_parent_handle` VARCHAR(255) NOT NULL COMMENT 'Parent Network\'s handle',
  `ine_son_handle` VARCHAR(255) NOT NULL COMMENT 'Son Network\'s handle',
  PRIMARY KEY (`ine_parent_handle`, `ine_son_handle`),
  INDEX `fk_ip_network_parent_relation_ip_network2_idx` (`ine_son_handle` ASC),
  UNIQUE INDEX `ine_son_handle_UNIQUE` (`ine_son_handle` ASC),
  CONSTRAINT `fk_ip_network_parent_relation_ip_network1`
    FOREIGN KEY (`ine_parent_handle`)
    REFERENCES `rdap`.`ip_network` (`ine_handle`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_ip_network_parent_relation_ip_network2`
    FOREIGN KEY (`ine_son_handle`)
    REFERENCES `rdap`.`ip_network` (`ine_handle`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an IP Network and its parent network.';


-- -----------------------------------------------------
-- Table `rdap`.`key_data`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`key_data` ;

CREATE TABLE IF NOT EXISTS `rdap`.`key_data` (
  `kd_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'Key data\'s id',
  `sdns_id` BIGINT NOT NULL COMMENT 'Secure DNS\'s id',
  `kd_flags` INT UNSIGNED NULL COMMENT 'Key data\'s flags',
  `kd_protocol` INT UNSIGNED NULL COMMENT 'Key data\'s protocol',
  `kd_public_key` VARCHAR(255) NULL COMMENT 'Key data\'s public key',
  `kd_algorithm` INT UNSIGNED NULL COMMENT 'Key data\'s algorithm',
  PRIMARY KEY (`kd_id`, `sdns_id`),
  INDEX `fk_key_data_secure_dns1_idx` (`sdns_id` ASC),
  CONSTRAINT `fk_key_data_secure_dns1`
    FOREIGN KEY (`sdns_id`)
    REFERENCES `rdap`.`secure_dns` (`sdns_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the information of the Key Data related to the Secure DNS information of a domain.';


-- -----------------------------------------------------
-- Table `rdap`.`key_links`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`key_links` ;

CREATE TABLE IF NOT EXISTS `rdap`.`key_links` (
  `kd_id` BIGINT NOT NULL COMMENT 'Key data\'s id',
  `lin_id` BIGINT NOT NULL COMMENT 'Link\'s id',
  PRIMARY KEY (`kd_id`, `lin_id`),
  INDEX `fk_key_links_link1_idx` (`lin_id` ASC),
  CONSTRAINT `fk_key_links_key_data1`
    FOREIGN KEY (`kd_id`)
    REFERENCES `rdap`.`key_data` (`kd_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_key_links_link1`
    FOREIGN KEY (`lin_id`)
    REFERENCES `rdap`.`link` (`lin_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the links related to a Key Data.';


-- -----------------------------------------------------
-- Table `rdap`.`key_events`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`key_events` ;

CREATE TABLE IF NOT EXISTS `rdap`.`key_events` (
  `kd_id` BIGINT NOT NULL COMMENT 'Key data\'s id',
  `eve_id` BIGINT NOT NULL COMMENT 'Event\'s id',
  PRIMARY KEY (`kd_id`, `eve_id`),
  INDEX `fk_key_events_event1_idx` (`eve_id` ASC),
  CONSTRAINT `fk_key_events_key_data1`
    FOREIGN KEY (`kd_id`)
    REFERENCES `rdap`.`key_data` (`kd_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_key_events_event1`
    FOREIGN KEY (`eve_id`)
    REFERENCES `rdap`.`event` (`eve_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the events related to a Key Data.';


-- -----------------------------------------------------
-- Table `rdap`.`link_lang`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`link_lang` ;

CREATE TABLE IF NOT EXISTS `rdap`.`link_lang` (
  `lin_id` BIGINT NOT NULL COMMENT 'Link\'s id',
  `lan_hreflang` VARCHAR(45) NOT NULL COMMENT 'Language',
  PRIMARY KEY (`lin_id`, `lan_hreflang`),
  CONSTRAINT `fk_link_hreflang_link1`
    FOREIGN KEY (`lin_id`)
    REFERENCES `rdap`.`link` (`lin_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the languages related to a link.';


-- -----------------------------------------------------
-- Table `rdap`.`entity_role`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`entity_role` ;

CREATE TABLE IF NOT EXISTS `rdap`.`entity_role` (
  `ent_id` BIGINT NOT NULL COMMENT 'Entity\'s id',
  `rol_id` TINYINT NOT NULL COMMENT 'Role\'s id',
  PRIMARY KEY (`ent_id`, `rol_id`),
  INDEX `fk_entity_role_roles1_idx` (`rol_id` ASC),
  UNIQUE INDEX `unique_ent_rol` (`ent_id` ASC, `rol_id` ASC),
  CONSTRAINT `fk_entity_role_entity1`
    FOREIGN KEY (`ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_entity_role_roles1`
    FOREIGN KEY (`rol_id`)
    REFERENCES `rdap`.`roles` (`rol_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'This table contains the relation between an Entity and its role.';

-- -----------------------------------------------------
-- Table `rdap`.`user_consent_by_attributes`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`user_consent_by_attributes` ;

CREATE TABLE IF NOT EXISTS `rdap`.`user_consent_by_attributes` (
  `ent_id` BIGINT NOT NULL,
  `uca_handle` TINYINT NOT NULL,
  `uca_name` TINYINT NOT NULL,
  `uca_companyName` TINYINT NOT NULL,
  `uca_companyURL` TINYINT NOT NULL,
  `uca_email` TINYINT NOT NULL,
  `uca_voice` TINYINT NOT NULL,
  `uca_cellphone` TINYINT NOT NULL,
  `uca_fax` TINYINT NOT NULL,
  `uca_jobTitle` TINYINT NOT NULL,
  `uca_contactUri` TINYINT NOT NULL,
  `uca_type` TINYINT NOT NULL,
  `uca_country` TINYINT NOT NULL,
  `uca_countryCode` TINYINT NOT NULL,
  `uca_city` TINYINT NOT NULL,
  `uca_state` TINYINT NOT NULL,
  `uca_street1` TINYINT NOT NULL,
  `uca_street2` TINYINT NOT NULL,
  `uca_street3` TINYINT NOT NULL,
  `uca_postalCode` TINYINT NOT NULL,
  PRIMARY KEY (`ent_id`),
  UNIQUE INDEX `ent_id_UNIQUE` (`ent_id` ASC),
  CONSTRAINT `fk_user_consent_by_attributes_entity`
    FOREIGN KEY (`ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'Table for user consent by attribute for contact information';

-- -----------------------------------------------------
-- Table `rdap`.`user_global_consent`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `rdap`.`user_global_consent` ;

CREATE TABLE IF NOT EXISTS `rdap`.`user_global_consent` (
  `ent_id` BIGINT NOT NULL,
  `ugc_consent` TINYINT NOT NULL,
  PRIMARY KEY (`ent_id`),
  UNIQUE INDEX `ent_id_UNIQUE` (`ent_id` ASC),
  CONSTRAINT `fk_user_global_consent_entity`
    FOREIGN KEY (`ent_id`)
    REFERENCES `rdap`.`entity` (`ent_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = 'Table for user global consent for contact information';

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;


-- -----------------------------------------------------
-- Insert catalogs
-- -----------------------------------------------------

INSERT INTO rdap.status VALUES(1,'validated');
INSERT INTO rdap.status VALUES(2,'renew prohibited');
INSERT INTO rdap.status VALUES(3,'update prohibited');
INSERT INTO rdap.status VALUES(4,'transfer prohibited');
INSERT INTO rdap.status VALUES(5,'delete prohibited');
INSERT INTO rdap.status VALUES(6,'proxy');
INSERT INTO rdap.status VALUES(7,'private');
INSERT INTO rdap.status VALUES(8,'removed');
INSERT INTO rdap.status VALUES(9,'obscured');
INSERT INTO rdap.status VALUES(10,'associated');
INSERT INTO rdap.status VALUES(11,'active');
INSERT INTO rdap.status VALUES(12,'inactive');
INSERT INTO rdap.status VALUES(13,'locked');
INSERT INTO rdap.status VALUES(14,'pending create');
INSERT INTO rdap.status VALUES(15,'pending renew');
INSERT INTO rdap.status VALUES(16,'pending transfer');
INSERT INTO rdap.status VALUES(17,'pending update');
INSERT INTO rdap.status VALUES(18,'pending delete');
INSERT INTO rdap.status VALUES(19, 'add period');
INSERT INTO rdap.status VALUES(20, 'auto renew period');
INSERT INTO rdap.status VALUES(21, 'client delete prohibited');
INSERT INTO rdap.status VALUES(22, 'client hold');
INSERT INTO rdap.status VALUES(23, 'client renew prohibited');
INSERT INTO rdap.status VALUES(24, 'client transfer prohibited');
INSERT INTO rdap.status VALUES(25, 'client update prohibited');
INSERT INTO rdap.status VALUES(26, 'pending restore');
INSERT INTO rdap.status VALUES(27, 'redemption period');
INSERT INTO rdap.status VALUES(28, 'renew period');
INSERT INTO rdap.status VALUES(29, 'server delete prohibited');
INSERT INTO rdap.status VALUES(30, 'server renew prohibited');
INSERT INTO rdap.status VALUES(31, 'server transfer prohibited');
INSERT INTO rdap.status VALUES(32, 'server update prohibited');
INSERT INTO rdap.status VALUES(33, 'server hold');
INSERT INTO rdap.status VALUES(34, 'transfer period');

INSERT INTO rdap.event_action VALUES(1,'registration');
INSERT INTO rdap.event_action VALUES(2,'reregistration');
INSERT INTO rdap.event_action VALUES(3,'last changed');
INSERT INTO rdap.event_action VALUES(4,'expiration');
INSERT INTO rdap.event_action VALUES(5,'deletion');
INSERT INTO rdap.event_action VALUES(6,'reinstantiation');
INSERT INTO rdap.event_action VALUES(7,'transfer');
INSERT INTO rdap.event_action VALUES(8,'locked');
INSERT INTO rdap.event_action VALUES(9,'unlocked');
INSERT INTO rdap.event_action VALUES(10,'last update of RDAP database');
INSERT INTO rdap.event_action VALUES(11,'registrar expiration');
INSERT INTO rdap.event_action VALUES(12,'enum validation expiration');

INSERT INTO rdap.relation VALUES(1, 'registered');
INSERT INTO rdap.relation VALUES(2, 'unregistered');
INSERT INTO rdap.relation VALUES(3, 'registration restricted');
INSERT INTO rdap.relation VALUES(4, 'open registration');
INSERT INTO rdap.relation VALUES(5, 'conjoined');

INSERT INTO rdap.roles VALUES (1,'registrant');
INSERT INTO rdap.roles VALUES (2,'technical');
INSERT INTO rdap.roles VALUES (3,'administrative');
INSERT INTO rdap.roles VALUES (4,'abuse');
INSERT INTO rdap.roles VALUES (5,'billing');
INSERT INTO rdap.roles VALUES (6,'registrar');
INSERT INTO rdap.roles VALUES (7,'reseller');
INSERT INTO rdap.roles VALUES (8,'sponsor');
INSERT INTO rdap.roles VALUES (9,'proxy');
INSERT INTO rdap.roles VALUES (10,'notifications');
INSERT INTO rdap.roles VALUES (11,'noc');

INSERT INTO rdap.country_code VALUES (4,'AF');
INSERT INTO rdap.country_code VALUES (248,'AX');
INSERT INTO rdap.country_code VALUES (8,'AL');
INSERT INTO rdap.country_code VALUES (12,'DZ');
INSERT INTO rdap.country_code VALUES (16,'AS');
INSERT INTO rdap.country_code VALUES (20,'AD');
INSERT INTO rdap.country_code VALUES (24,'AO');
INSERT INTO rdap.country_code VALUES (660,'AI');
INSERT INTO rdap.country_code VALUES (10,'AQ');
INSERT INTO rdap.country_code VALUES (28,'AG');
INSERT INTO rdap.country_code VALUES (32,'AR');
INSERT INTO rdap.country_code VALUES (51,'AM');
INSERT INTO rdap.country_code VALUES (533,'AW');
INSERT INTO rdap.country_code VALUES (36,'AU');
INSERT INTO rdap.country_code VALUES (40,'AT');
INSERT INTO rdap.country_code VALUES (31,'AZ');
INSERT INTO rdap.country_code VALUES (44,'BS');
INSERT INTO rdap.country_code VALUES (48,'BH');
INSERT INTO rdap.country_code VALUES (50,'BD');
INSERT INTO rdap.country_code VALUES (52,'BB');
INSERT INTO rdap.country_code VALUES (112,'BY');
INSERT INTO rdap.country_code VALUES (56,'BE');
INSERT INTO rdap.country_code VALUES (84,'BZ');
INSERT INTO rdap.country_code VALUES (204,'BJ');
INSERT INTO rdap.country_code VALUES (60,'BM');
INSERT INTO rdap.country_code VALUES (64,'BT');
INSERT INTO rdap.country_code VALUES (68,'BO');
INSERT INTO rdap.country_code VALUES (70,'BA');
INSERT INTO rdap.country_code VALUES (72,'BW');
INSERT INTO rdap.country_code VALUES (74,'BV');
INSERT INTO rdap.country_code VALUES (76,'BR');
INSERT INTO rdap.country_code VALUES (92,'VG');
INSERT INTO rdap.country_code VALUES (86,'IO');
INSERT INTO rdap.country_code VALUES (96,'BN');
INSERT INTO rdap.country_code VALUES (100,'BG');
INSERT INTO rdap.country_code VALUES (854,'BF');
INSERT INTO rdap.country_code VALUES (108,'BI');
INSERT INTO rdap.country_code VALUES (116,'KH');
INSERT INTO rdap.country_code VALUES (120,'CM');
INSERT INTO rdap.country_code VALUES (124,'CA');
INSERT INTO rdap.country_code VALUES (132,'CV');
INSERT INTO rdap.country_code VALUES (136,'KY');
INSERT INTO rdap.country_code VALUES (140,'CF');
INSERT INTO rdap.country_code VALUES (148,'TD');
INSERT INTO rdap.country_code VALUES (152,'CL');
INSERT INTO rdap.country_code VALUES (156,'CN');
INSERT INTO rdap.country_code VALUES (344,'HK');
INSERT INTO rdap.country_code VALUES (446,'MO');
INSERT INTO rdap.country_code VALUES (162,'CX');
INSERT INTO rdap.country_code VALUES (166,'CC');
INSERT INTO rdap.country_code VALUES (170,'CO');
INSERT INTO rdap.country_code VALUES (174,'KM');
INSERT INTO rdap.country_code VALUES (178,'CG');
INSERT INTO rdap.country_code VALUES (180,'CD');
INSERT INTO rdap.country_code VALUES (184,'CK');
INSERT INTO rdap.country_code VALUES (188,'CR');
INSERT INTO rdap.country_code VALUES (384,'CI');
INSERT INTO rdap.country_code VALUES (191,'HR');
INSERT INTO rdap.country_code VALUES (192,'CU');
INSERT INTO rdap.country_code VALUES (196,'CY');
INSERT INTO rdap.country_code VALUES (203,'CZ');
INSERT INTO rdap.country_code VALUES (208,'DK');
INSERT INTO rdap.country_code VALUES (262,'DJ');
INSERT INTO rdap.country_code VALUES (212,'DM');
INSERT INTO rdap.country_code VALUES (214,'DO');
INSERT INTO rdap.country_code VALUES (218,'EC');
INSERT INTO rdap.country_code VALUES (818,'EG');
INSERT INTO rdap.country_code VALUES (222,'SV');
INSERT INTO rdap.country_code VALUES (226,'GQ');
INSERT INTO rdap.country_code VALUES (232,'ER');
INSERT INTO rdap.country_code VALUES (233,'EE');
INSERT INTO rdap.country_code VALUES (231,'ET');
INSERT INTO rdap.country_code VALUES (238,'FK');
INSERT INTO rdap.country_code VALUES (234,'FO');
INSERT INTO rdap.country_code VALUES (242,'FJ');
INSERT INTO rdap.country_code VALUES (246,'FI');
INSERT INTO rdap.country_code VALUES (250,'FR');
INSERT INTO rdap.country_code VALUES (254,'GF');
INSERT INTO rdap.country_code VALUES (258,'PF');
INSERT INTO rdap.country_code VALUES (260,'TF');
INSERT INTO rdap.country_code VALUES (266,'GA');
INSERT INTO rdap.country_code VALUES (270,'GM');
INSERT INTO rdap.country_code VALUES (268,'GE');
INSERT INTO rdap.country_code VALUES (276,'DE');
INSERT INTO rdap.country_code VALUES (288,'GH');
INSERT INTO rdap.country_code VALUES (292,'GI');
INSERT INTO rdap.country_code VALUES (300,'GR');
INSERT INTO rdap.country_code VALUES (304,'GL');
INSERT INTO rdap.country_code VALUES (308,'GD');
INSERT INTO rdap.country_code VALUES (312,'GP');
INSERT INTO rdap.country_code VALUES (316,'GU');
INSERT INTO rdap.country_code VALUES (320,'GT');
INSERT INTO rdap.country_code VALUES (831,'GG');
INSERT INTO rdap.country_code VALUES (324,'GN');
INSERT INTO rdap.country_code VALUES (624,'GW');
INSERT INTO rdap.country_code VALUES (328,'GY');
INSERT INTO rdap.country_code VALUES (332,'HT');
INSERT INTO rdap.country_code VALUES (334,'HM');
INSERT INTO rdap.country_code VALUES (336,'VA');
INSERT INTO rdap.country_code VALUES (340,'HN');
INSERT INTO rdap.country_code VALUES (348,'HU');
INSERT INTO rdap.country_code VALUES (352,'IS');
INSERT INTO rdap.country_code VALUES (356,'IN');
INSERT INTO rdap.country_code VALUES (360,'ID');
INSERT INTO rdap.country_code VALUES (364,'IR');
INSERT INTO rdap.country_code VALUES (368,'IQ');
INSERT INTO rdap.country_code VALUES (372,'IE');
INSERT INTO rdap.country_code VALUES (833,'IM');
INSERT INTO rdap.country_code VALUES (376,'IL');
INSERT INTO rdap.country_code VALUES (380,'IT');
INSERT INTO rdap.country_code VALUES (388,'JM');
INSERT INTO rdap.country_code VALUES (392,'JP');
INSERT INTO rdap.country_code VALUES (832,'JE');
INSERT INTO rdap.country_code VALUES (400,'JO');
INSERT INTO rdap.country_code VALUES (398,'KZ');
INSERT INTO rdap.country_code VALUES (404,'KE');
INSERT INTO rdap.country_code VALUES (296,'KI');
INSERT INTO rdap.country_code VALUES (408,'KP');
INSERT INTO rdap.country_code VALUES (410,'KR');
INSERT INTO rdap.country_code VALUES (414,'KW');
INSERT INTO rdap.country_code VALUES (417,'KG');
INSERT INTO rdap.country_code VALUES (418,'LA');
INSERT INTO rdap.country_code VALUES (428,'LV');
INSERT INTO rdap.country_code VALUES (422,'LB');
INSERT INTO rdap.country_code VALUES (426,'LS');
INSERT INTO rdap.country_code VALUES (430,'LR');
INSERT INTO rdap.country_code VALUES (434,'LY');
INSERT INTO rdap.country_code VALUES (438,'LI');
INSERT INTO rdap.country_code VALUES (440,'LT');
INSERT INTO rdap.country_code VALUES (442,'LU');
INSERT INTO rdap.country_code VALUES (807,'MK');
INSERT INTO rdap.country_code VALUES (450,'MG');
INSERT INTO rdap.country_code VALUES (454,'MW');
INSERT INTO rdap.country_code VALUES (458,'MY');
INSERT INTO rdap.country_code VALUES (462,'MV');
INSERT INTO rdap.country_code VALUES (466,'ML');
INSERT INTO rdap.country_code VALUES (470,'MT');
INSERT INTO rdap.country_code VALUES (584,'MH');
INSERT INTO rdap.country_code VALUES (474,'MQ');
INSERT INTO rdap.country_code VALUES (478,'MR');
INSERT INTO rdap.country_code VALUES (480,'MU');
INSERT INTO rdap.country_code VALUES (175,'YT');
INSERT INTO rdap.country_code VALUES (484,'MX');
INSERT INTO rdap.country_code VALUES (583,'FM');
INSERT INTO rdap.country_code VALUES (498,'MD');
INSERT INTO rdap.country_code VALUES (492,'MC');
INSERT INTO rdap.country_code VALUES (496,'MN');
INSERT INTO rdap.country_code VALUES (499,'ME');
INSERT INTO rdap.country_code VALUES (500,'MS');
INSERT INTO rdap.country_code VALUES (504,'MA');
INSERT INTO rdap.country_code VALUES (508,'MZ');
INSERT INTO rdap.country_code VALUES (104,'MM');
INSERT INTO rdap.country_code VALUES (516,'NA');
INSERT INTO rdap.country_code VALUES (520,'NR');
INSERT INTO rdap.country_code VALUES (524,'NP');
INSERT INTO rdap.country_code VALUES (528,'NL');
INSERT INTO rdap.country_code VALUES (530,'AN');
INSERT INTO rdap.country_code VALUES (540,'NC');
INSERT INTO rdap.country_code VALUES (554,'NZ');
INSERT INTO rdap.country_code VALUES (558,'NI');
INSERT INTO rdap.country_code VALUES (562,'NE');
INSERT INTO rdap.country_code VALUES (566,'NG');
INSERT INTO rdap.country_code VALUES (570,'NU');
INSERT INTO rdap.country_code VALUES (574,'NF');
INSERT INTO rdap.country_code VALUES (580,'MP');
INSERT INTO rdap.country_code VALUES (578,'NO');
INSERT INTO rdap.country_code VALUES (512,'OM');
INSERT INTO rdap.country_code VALUES (586,'PK');
INSERT INTO rdap.country_code VALUES (585,'PW');
INSERT INTO rdap.country_code VALUES (275,'PS');
INSERT INTO rdap.country_code VALUES (591,'PA');
INSERT INTO rdap.country_code VALUES (598,'PG');
INSERT INTO rdap.country_code VALUES (600,'PY');
INSERT INTO rdap.country_code VALUES (604,'PE');
INSERT INTO rdap.country_code VALUES (608,'PH');
INSERT INTO rdap.country_code VALUES (612,'PN');
INSERT INTO rdap.country_code VALUES (616,'PL');
INSERT INTO rdap.country_code VALUES (620,'PT');
INSERT INTO rdap.country_code VALUES (630,'PR');
INSERT INTO rdap.country_code VALUES (634,'QA');
INSERT INTO rdap.country_code VALUES (638,'RE');
INSERT INTO rdap.country_code VALUES (642,'RO');
INSERT INTO rdap.country_code VALUES (643,'RU');
INSERT INTO rdap.country_code VALUES (646,'RW');
INSERT INTO rdap.country_code VALUES (652,'BL');
INSERT INTO rdap.country_code VALUES (654,'SH');
INSERT INTO rdap.country_code VALUES (659,'KN');
INSERT INTO rdap.country_code VALUES (662,'LC');
INSERT INTO rdap.country_code VALUES (663,'MF');
INSERT INTO rdap.country_code VALUES (666,'PM');
INSERT INTO rdap.country_code VALUES (670,'VC');
INSERT INTO rdap.country_code VALUES (882,'WS');
INSERT INTO rdap.country_code VALUES (674,'SM');
INSERT INTO rdap.country_code VALUES (678,'ST');
INSERT INTO rdap.country_code VALUES (682,'SA');
INSERT INTO rdap.country_code VALUES (686,'SN');
INSERT INTO rdap.country_code VALUES (688,'RS');
INSERT INTO rdap.country_code VALUES (690,'SC');
INSERT INTO rdap.country_code VALUES (694,'SL');
INSERT INTO rdap.country_code VALUES (702,'SG');
INSERT INTO rdap.country_code VALUES (703,'SK');
INSERT INTO rdap.country_code VALUES (705,'SI');
INSERT INTO rdap.country_code VALUES (90,'SB');
INSERT INTO rdap.country_code VALUES (706,'SO');
INSERT INTO rdap.country_code VALUES (710,'ZA');
INSERT INTO rdap.country_code VALUES (239,'GS');
INSERT INTO rdap.country_code VALUES (728,'SS');
INSERT INTO rdap.country_code VALUES (724,'ES');
INSERT INTO rdap.country_code VALUES (144,'LK');
INSERT INTO rdap.country_code VALUES (736,'SD');
INSERT INTO rdap.country_code VALUES (740,'SR');
INSERT INTO rdap.country_code VALUES (744,'SJ');
INSERT INTO rdap.country_code VALUES (748,'SZ');
INSERT INTO rdap.country_code VALUES (752,'SE');
INSERT INTO rdap.country_code VALUES (756,'CH');
INSERT INTO rdap.country_code VALUES (760,'SY');
INSERT INTO rdap.country_code VALUES (158,'TW');
INSERT INTO rdap.country_code VALUES (762,'TJ');
INSERT INTO rdap.country_code VALUES (834,'TZ');
INSERT INTO rdap.country_code VALUES (764,'TH');
INSERT INTO rdap.country_code VALUES (626,'TL');
INSERT INTO rdap.country_code VALUES (768,'TG');
INSERT INTO rdap.country_code VALUES (772,'TK');
INSERT INTO rdap.country_code VALUES (776,'TO');
INSERT INTO rdap.country_code VALUES (780,'TT');
INSERT INTO rdap.country_code VALUES (788,'TN');
INSERT INTO rdap.country_code VALUES (792,'TR');
INSERT INTO rdap.country_code VALUES (795,'TM');
INSERT INTO rdap.country_code VALUES (796,'TC');
INSERT INTO rdap.country_code VALUES (798,'TV');
INSERT INTO rdap.country_code VALUES (800,'UG');
INSERT INTO rdap.country_code VALUES (804,'UA');
INSERT INTO rdap.country_code VALUES (784,'AE');
INSERT INTO rdap.country_code VALUES (826,'GB');
INSERT INTO rdap.country_code VALUES (840,'US');
INSERT INTO rdap.country_code VALUES (581,'UM');
INSERT INTO rdap.country_code VALUES (858,'UY');
INSERT INTO rdap.country_code VALUES (860,'UZ');
INSERT INTO rdap.country_code VALUES (548,'VU');
INSERT INTO rdap.country_code VALUES (862,'VE');
INSERT INTO rdap.country_code VALUES (704,'VN');
INSERT INTO rdap.country_code VALUES (850,'VI');
INSERT INTO rdap.country_code VALUES (876,'WF');
INSERT INTO rdap.country_code VALUES (732,'EH');
INSERT INTO rdap.country_code VALUES (887,'YE');
INSERT INTO rdap.country_code VALUES (894,'ZM');
INSERT INTO rdap.country_code VALUES (716,'ZW');
INSERT INTO rdap.country_code VALUES (531,'CW');
INSERT INTO rdap.country_code VALUES (534,'SX');
INSERT INTO rdap.country_code VALUES (535,'BQ');

INSERT INTO rdap.ip_version VALUES (4, 'v4');
INSERT INTO rdap.ip_version VALUES (6, 'v6');

commit;