--
-- MySQL database dump Mapbender 2.5
--
-- --------------------------------------------------------


DELIMITER $$

DROP FUNCTION IF EXISTS gettext$$


CREATE FUNCTION gettext(locale_arg text, querystring text) RETURNS text READS SQL DATA

BEGIN

DECLARE result text;

SELECT msgstr INTO result FROM translations WHERE locale = locale_arg AND msgid = querystring;

IF result IS NULL THEN
RETURN querystring;
ELSE
RETURN result;
END IF;

END$$

DELIMITER ;

-- 
-- Tabellenstruktur für Tabelle 'gui'
-- 

CREATE TABLE IF NOT EXISTS gui (
  gui_id varchar(50) NOT NULL default '',
  gui_name varchar(50) NOT NULL default '',
  gui_description varchar(255) NOT NULL default '',
  gui_public tinyint(4) NOT NULL default '1',
  PRIMARY KEY  (gui_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'gui'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'gui_element'
-- 

CREATE TABLE IF NOT EXISTS gui_element (
  fkey_gui_id varchar(50) NOT NULL default '',
  e_id varchar(50) NOT NULL default '',
  e_pos tinyint(4) unsigned zerofill default NULL,
  e_public tinyint(1) unsigned zerofill default NULL,
  e_comment text,
  e_title varchar(255) default NULL,
  e_element varchar(255) NOT NULL default '',
  e_src varchar(255) default NULL,
  e_attributes longtext,
  e_left int(4) default NULL,
  e_top int(4) default NULL,
  e_width int(4) unsigned default NULL,
  e_height int(4) unsigned default NULL,
  e_z_index tinyint(3) unsigned default NULL,
  e_more_styles longtext,
  e_content longtext,
  e_closetag varchar(255) default NULL,
  e_js_file varchar(50) default NULL,
  e_mb_mod varchar(50) default NULL,
  e_target varchar(50) default NULL,
  e_requires varchar(50) default NULL,
  e_url varchar(255) default NULL,
  PRIMARY KEY  (fkey_gui_id,e_id),
  KEY idx_gui_id_e_id (fkey_gui_id,e_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'gui_element'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'gui_element_vars'
-- 

CREATE TABLE IF NOT EXISTS gui_element_vars (
  fkey_gui_id varchar(50) NOT NULL default '',
  fkey_e_id varchar(50) NOT NULL default '',
  var_name varchar(50) NOT NULL default '',
  var_value text,
  `context` text,
  var_type varchar(50) default NULL,
  PRIMARY KEY  (fkey_gui_id,fkey_e_id,var_name),
  KEY idx_elementvars (fkey_gui_id,fkey_e_id,var_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'gui_element_vars'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'gui_kml'
-- 

CREATE TABLE IF NOT EXISTS gui_kml (
  kml_id int(11) NOT NULL auto_increment,
  fkey_mb_user_id int(11) NOT NULL,
  fkey_gui_id varchar(50) NOT NULL,
  kml_doc text NOT NULL,
  kml_name varchar(64) default NULL,
  kml_description text,
  kml_timestamp int(11) NOT NULL,
  PRIMARY KEY  (kml_id),
  KEY gui_kml_fkey_mb_user_id (fkey_mb_user_id),
  KEY gui_kml_id_fkey_gui_id (fkey_gui_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'gui_kml'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'gui_layer'
-- 

CREATE TABLE IF NOT EXISTS gui_layer (
  fkey_gui_id varchar(50) NOT NULL default '',
  fkey_layer_id int(11) NOT NULL default '0',
  gui_layer_wms_id int(11) default '0',
  gui_layer_status smallint(6) default '1',
  gui_layer_selectable smallint(6) default '1',
  gui_layer_visible smallint(6) default '1',
  gui_layer_queryable smallint(6) default '0',
  gui_layer_querylayer int(11) default '0',
  gui_layer_minscale int(11) unsigned default '0',
  gui_layer_maxscale int(11) unsigned default '0',
  gui_layer_priority int(6) default NULL,
  gui_layer_style varchar(50) default NULL,
  gui_layer_wfs_featuretype varchar(255) default NULL,
  PRIMARY KEY  (fkey_gui_id,fkey_layer_id),
  KEY gui_index (fkey_gui_id),
  KEY layer_index (fkey_layer_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'gui_layer'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'gui_mb_group'
-- 

CREATE TABLE IF NOT EXISTS gui_mb_group (
  fkey_gui_id varchar(50) NOT NULL default '',
  fkey_mb_group_id int(11) NOT NULL default '0',
  mb_group_type varchar(50) NOT NULL default '',
  PRIMARY KEY  (fkey_gui_id,fkey_mb_group_id),
  KEY fkey_mb_group_id (fkey_mb_group_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'gui_mb_group'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'gui_mb_user'
-- 

CREATE TABLE IF NOT EXISTS gui_mb_user (
  fkey_gui_id varchar(50) NOT NULL default '',
  fkey_mb_user_id int(11) NOT NULL default '0',
  mb_user_type varchar(50) default NULL,
  PRIMARY KEY  (fkey_gui_id,fkey_mb_user_id),
  KEY fkey_mb_user_id (fkey_mb_user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'gui_mb_user'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'gui_treegde'
-- 

CREATE TABLE IF NOT EXISTS gui_treegde (
  fkey_gui_id varchar(50) NOT NULL default '',
  fkey_layer_id text,
  id int(11) NOT NULL auto_increment,
  lft int(11) NOT NULL default '0',
  rgt int(11) NOT NULL default '0',
  my_layer_title varchar(50) default NULL,
  layer text,
  wms_id text,
  PRIMARY KEY  (fkey_gui_id,id,lft,rgt),
  KEY tree_ind (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'gui_treegde'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'gui_wfs'
-- 

CREATE TABLE IF NOT EXISTS gui_wfs (
  fkey_gui_id varchar(50) NOT NULL default '',
  fkey_wfs_id int(11) NOT NULL default '0',
  PRIMARY KEY  (fkey_gui_id,fkey_wfs_id),
  KEY fkey_wfs_id (fkey_wfs_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'gui_wfs'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'gui_wfs_conf'
-- 

CREATE TABLE IF NOT EXISTS gui_wfs_conf (
  fkey_gui_id varchar(50) NOT NULL default '',
  fkey_wfs_conf_id int(11) NOT NULL default '0',
  PRIMARY KEY  (fkey_gui_id,fkey_wfs_conf_id),
  KEY gui_wfs_conf_ibfk_2 (fkey_wfs_conf_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'gui_wfs_conf'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'gui_wms'
-- 

CREATE TABLE IF NOT EXISTS gui_wms (
  fkey_gui_id varchar(50) NOT NULL default '',
  fkey_wms_id int(11) NOT NULL default '0',
  gui_wms_position int(11) NOT NULL default '0',
  gui_wms_mapformat varchar(50) NOT NULL default '',
  gui_wms_featureinfoformat varchar(50) NOT NULL default '',
  gui_wms_exceptionformat varchar(50) NOT NULL default '',
  gui_wms_epsg varchar(50) NOT NULL default '',
  gui_wms_visible smallint(6) NOT NULL default '1',
  gui_wms_sldurl varchar(255) NOT NULL default '',
  gui_wms_opacity int(11) default '100',
  PRIMARY KEY  (fkey_gui_id,fkey_wms_id),
  KEY gui_wms_ibfk_4 (fkey_wms_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'gui_wms'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'keyword'
-- 

CREATE TABLE IF NOT EXISTS keyword (
  keyword_id int(11) NOT NULL auto_increment,
  keyword varchar(255) NOT NULL,
  PRIMARY KEY  (keyword_id),
  UNIQUE KEY keyword_keyword_key (keyword),
  KEY ind_keyword (keyword)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'keyword'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'layer'
-- 

CREATE TABLE IF NOT EXISTS layer (
  layer_id int(11) NOT NULL auto_increment,
  fkey_wms_id int(11) NOT NULL default '0',
  layer_pos int(11) NOT NULL default '0',
  layer_parent varchar(50) NOT NULL default '',
  layer_name varchar(255) NOT NULL default '',
  layer_title varchar(255) NOT NULL default '',
  layer_queryable smallint(6) NOT NULL default '0',
  layer_minscale int(11) default '0',
  layer_maxscale int(11) default '0',
  layer_dataurl varchar(255) default NULL,
  layer_metadataurl varchar(255) default NULL,
  layer_abstract text,
  PRIMARY KEY  (layer_id),
  KEY wms_index (fkey_wms_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'layer'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'layer_epsg'
-- 

CREATE TABLE IF NOT EXISTS layer_epsg (
  fkey_layer_id int(11) NOT NULL default '0',
  epsg varchar(50) NOT NULL default '',
  minx double default '0',
  miny double default '0',
  maxx double default '0',
  maxy double default '0',
  KEY layer_index (fkey_layer_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'layer_epsg'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'layer_keyword'
-- 

CREATE TABLE IF NOT EXISTS layer_keyword (
  fkey_layer_id int(11) NOT NULL,
  fkey_keyword_id int(11) NOT NULL,
  PRIMARY KEY  (fkey_layer_id,fkey_keyword_id),
  KEY fkey_keyword_id_fkey_layer_id (fkey_keyword_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'layer_keyword'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'layer_load_count'
-- 

CREATE TABLE IF NOT EXISTS layer_load_count (
  fkey_layer_id int(11) default NULL,
  load_count bigint(20) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'layer_load_count'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'layer_style'
-- 

CREATE TABLE IF NOT EXISTS layer_style (
  fkey_layer_id int(11) NOT NULL default '0',
  `name` varchar(50) NOT NULL default '',
  title varchar(100) NOT NULL default '',
  legendurl varchar(255) default NULL,
  legendurlformat varchar(50) default NULL,
  KEY layer_index (fkey_layer_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'layer_style'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'mb_group'
-- 

CREATE TABLE IF NOT EXISTS mb_group (
  mb_group_id int(11) NOT NULL auto_increment,
  mb_group_name varchar(50) NOT NULL default '',
  mb_group_owner int(4) default NULL,
  mb_group_description varchar(255) NOT NULL default '',
  PRIMARY KEY  (mb_group_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'mb_group'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'mb_log'
-- 

CREATE TABLE IF NOT EXISTS mb_log (
  id bigint(20) NOT NULL auto_increment,
  time_client varchar(13) default '0',
  time_server varchar(13) default NULL,
  time_readable varchar(50) default NULL,
  mb_session varchar(50) default NULL,
  gui varchar(50) default NULL,
  module varchar(50) default NULL,
  ip varchar(20) default NULL,
  username varchar(50) default NULL,
  userid varchar(50) default NULL,
  request text,
  PRIMARY KEY  (id),
  KEY logindex (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'mb_log'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'mb_monitor'
-- 

CREATE TABLE IF NOT EXISTS mb_monitor (
  upload_id varchar(255) NOT NULL default '',
  fkey_wms_id int(11) NOT NULL default '0',
  `status` int(11) NOT NULL,
  status_comment varchar(255) NOT NULL default '',
  timestamp_begin int(11) NOT NULL,
  timestamp_end int(11) NOT NULL,
  upload_url varchar(255) NOT NULL default '',
  updated char(1) NOT NULL default '',
  image int(11) default NULL,
  map_url varchar(2048) default NULL,
  PRIMARY KEY  (upload_id,fkey_wms_id),
  KEY mb_monitor_ibfk_1 (fkey_wms_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'mb_monitor'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'mb_user'
-- 

CREATE TABLE IF NOT EXISTS mb_user (
  mb_user_id int(11) NOT NULL auto_increment,
  mb_user_name varchar(50) NOT NULL default '',
  mb_user_password varchar(50) NOT NULL default '',
  mb_user_owner int(11) NOT NULL default '0',
  mb_user_description varchar(255) default NULL,
  mb_user_login_count int(4) unsigned NOT NULL default '0',
  mb_user_email varchar(50) default NULL,
  mb_user_phone varchar(50) default NULL,
  mb_user_department varchar(255) default NULL,
  mb_user_resolution int(4) NOT NULL default '72',
  mb_user_organisation_name varchar(255) default NULL,
  mb_user_position_name varchar(255) default NULL,
  mb_user_phone1 varchar(255) default NULL,
  mb_user_facsimile varchar(255) default NULL,
  mb_user_delivery_point varchar(255) default NULL,
  mb_user_city varchar(255) default NULL,
  mb_user_postal_code int(4) default NULL,
  mb_user_country varchar(255) default NULL,
  mb_user_online_resource varchar(255) default NULL,
  PRIMARY KEY  (mb_user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'mb_user'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'mb_user_mb_group'
-- 

CREATE TABLE IF NOT EXISTS mb_user_mb_group (
  fkey_mb_user_id int(11) NOT NULL default '0',
  fkey_mb_group_id int(11) NOT NULL default '0',
  PRIMARY KEY  (fkey_mb_user_id,fkey_mb_group_id),
  KEY fkey_mb_group_id (fkey_mb_group_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'mb_user_mb_group'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'mb_user_wmc'
-- 

CREATE TABLE IF NOT EXISTS mb_user_wmc (
  wmc_id varchar(20) NOT NULL default '',
  fkey_user_id int(11) NOT NULL default '0',
  wmc longtext NOT NULL,
  wmc_title varchar(50) default NULL,
  wmc_timestamp int(10) default NULL,
  PRIMARY KEY  (wmc_id),
  KEY fkey_user_id (fkey_user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'mb_user_wmc'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'md_topic_category'
-- 

CREATE TABLE IF NOT EXISTS md_topic_category (
  md_topic_category_id int(11) NOT NULL auto_increment,
  md_topic_category_code_en varchar(255) default NULL,
  md_topic_category_code_de varchar(255) default NULL,
  PRIMARY KEY  (md_topic_category_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'md_topic_category'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'sld_user_layer'
-- 

CREATE TABLE IF NOT EXISTS sld_user_layer (
  sld_user_layer_id int(11) NOT NULL auto_increment,
  fkey_mb_user_id int(11) NOT NULL default '0',
  fkey_layer_id int(11) NOT NULL default '0',
  fkey_gui_id varchar(50) NOT NULL default '',
  sld_xml text,
  use_sld tinyint(1) default '0',
  PRIMARY KEY  (sld_user_layer_id),
  KEY sld_user_layer_ibfk1 (fkey_mb_user_id),
  KEY sld_user_layer_ibfk2 (fkey_layer_id),
  KEY sld_user_layer_ibfk3 (fkey_gui_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'sld_user_layer'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'translations'
-- 

CREATE TABLE IF NOT EXISTS translations (
  trs_id int(11) NOT NULL auto_increment,
  locale varchar(8) default NULL,
  msgid varchar(512) default NULL,
  msgstr varchar(512) default NULL,
  PRIMARY KEY  (trs_id),
  KEY msgid_idx (msgid(255))
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'translations'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'wfs'
-- 

CREATE TABLE IF NOT EXISTS wfs (
  wfs_id int(11) NOT NULL auto_increment,
  wfs_version varchar(50) NOT NULL default '''''',
  wfs_name varchar(255) default NULL,
  wfs_title varchar(255) NOT NULL default '''''',
  wfs_abstract text,
  wfs_getcapabilities varchar(255) NOT NULL default '''''',
  wfs_describefeaturetype varchar(255) default NULL,
  wfs_getfeature varchar(255) default NULL,
  wfs_transaction varchar(255) default NULL,
  wfs_owsproxy varchar(50) default NULL,
  wfs_getcapabilities_doc text,
  wfs_upload_url varchar(255) default NULL,
  fees varchar(255) default NULL,
  accessconstraints text,
  individualname varchar(255) default NULL,
  positionname varchar(255) default NULL,
  providername varchar(255) default NULL,
  city varchar(255) default NULL,
  deliverypoint varchar(255) default NULL,
  administrativearea varchar(255) default NULL,
  postalcode varchar(255) default NULL,
  voice varchar(255) default NULL,
  facsimile varchar(255) default NULL,
  electronicmailaddress varchar(255) default NULL,
  wfs_mb_getcapabilities_doc text,
  wfs_owner int(11) default NULL,
  wfs_timestamp int(11) default NULL,
  country varchar(255) default NULL,
  PRIMARY KEY  (wfs_id),
  KEY wfs_ (wfs_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'wfs'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'wfs_conf'
-- 

CREATE TABLE IF NOT EXISTS wfs_conf (
  wfs_conf_id int(11) NOT NULL auto_increment,
  wfs_conf_abstract text,
  fkey_wfs_id int(11) NOT NULL default '0',
  fkey_featuretype_id int(11) NOT NULL default '0',
  g_label varchar(50) default NULL,
  g_label_id varchar(50) default NULL,
  g_button varchar(50) default NULL,
  g_button_id varchar(50) default NULL,
  g_style text,
  g_buffer float default '0',
  g_res_style text,
  g_use_wzgraphics int(10) unsigned default '0',
  wfs_conf_description text,
  PRIMARY KEY  (wfs_conf_id),
  KEY fkey_wfs_id (fkey_wfs_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'wfs_conf'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'wfs_conf_element'
-- 

CREATE TABLE IF NOT EXISTS wfs_conf_element (
  wfs_conf_element_id int(11) unsigned NOT NULL auto_increment,
  fkey_wfs_conf_id int(11) NOT NULL default '0',
  f_id int(11) NOT NULL default '0',
  f_geom tinyint(3) unsigned default '0',
  f_gid tinyint(3) unsigned NOT NULL default '0',
  f_search tinyint(3) unsigned default NULL,
  f_pos int(11) default NULL,
  f_style_id varchar(255) default NULL,
  f_toupper int(11) unsigned default NULL,
  f_label varchar(255) default NULL,
  f_label_id varchar(50) default NULL,
  f_show tinyint(3) unsigned default NULL,
  f_respos int(11) default NULL,
  f_form_element_html text,
  f_edit int(11) default NULL,
  f_mandatory int(11) default NULL,
  f_auth_varname varchar(50) default NULL,
  f_show_detail int(11) default NULL,
  f_operator varchar(50) default NULL,
  PRIMARY KEY  (wfs_conf_element_id),
  KEY fkey_wfs_conf_id (fkey_wfs_conf_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'wfs_conf_element'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'wfs_element'
-- 

CREATE TABLE IF NOT EXISTS wfs_element (
  fkey_featuretype_id int(11) NOT NULL default '0',
  element_id int(11) NOT NULL auto_increment,
  element_name varchar(50) default NULL,
  element_type varchar(50) default NULL,
  PRIMARY KEY  (fkey_featuretype_id,element_id),
  KEY element_ind0 (fkey_featuretype_id),
  KEY element_ind1 (element_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'wfs_element'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'wfs_featuretype'
-- 

CREATE TABLE IF NOT EXISTS wfs_featuretype (
  fkey_wfs_id int(11) NOT NULL default '0',
  featuretype_id int(11) NOT NULL auto_increment,
  featuretype_name varchar(50) NOT NULL default '',
  featuretype_title varchar(50) default NULL,
  featuretype_srs varchar(50) default NULL,
  featuretype_searchable int(11) default '1',
  featuretype_abstract varchar(50) default NULL,
  PRIMARY KEY  (featuretype_id),
  KEY wfs_ind (fkey_wfs_id),
  KEY wfs_ind2 (featuretype_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'wfs_featuretype'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'wfs_featuretype_keyword'
-- 

CREATE TABLE IF NOT EXISTS wfs_featuretype_keyword (
  fkey_featuretype_id int(11) NOT NULL,
  fkey_keyword_id int(11) NOT NULL,
  KEY fkey_keyword_id_fkey_featuretype_id (fkey_keyword_id),
  KEY fkey_featuretype_id_fkey_keyword_id (fkey_featuretype_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'wfs_featuretype_keyword'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'wfs_featuretype_namespace'
-- 

CREATE TABLE IF NOT EXISTS wfs_featuretype_namespace (
  fkey_wfs_id int(11) NOT NULL default '0',
  fkey_featuretype_id int(11) NOT NULL default '0',
  namespace varchar(255) NOT NULL default '',
  namespace_location varchar(255) NOT NULL default '',
  PRIMARY KEY  (fkey_wfs_id,fkey_featuretype_id,namespace),
  KEY wfs_id (fkey_wfs_id),
  KEY featuretype_id (fkey_featuretype_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'wfs_featuretype_namespace'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'wms'
-- 

CREATE TABLE IF NOT EXISTS wms (
  wms_id int(11) NOT NULL auto_increment,
  wms_version varchar(50) NOT NULL default '',
  wms_title varchar(255) NOT NULL default '',
  wms_abstract text,
  wms_getcapabilities varchar(255) NOT NULL default '',
  wms_getmap varchar(255) NOT NULL default '',
  wms_getfeatureinfo varchar(255) NOT NULL default '',
  wms_getlegendurl varchar(255) default NULL,
  wms_filter varchar(255) default NULL,
  wms_getcapabilities_doc longtext,
  wms_owsproxy varchar(50) default NULL,
  wms_upload_url varchar(255) default NULL,
  fees varchar(255) default NULL,
  accessconstraints text,
  contactperson varchar(255) default NULL,
  contactposition varchar(255) default NULL,
  contactorganization varchar(255) default NULL,
  address varchar(255) default NULL,
  city varchar(255) default NULL,
  stateorprovince varchar(255) default NULL,
  postcode varchar(255) default NULL,
  country varchar(255) default NULL,
  contactvoicetelephone varchar(255) default NULL,
  contactfacsimiletelephone varchar(255) default NULL,
  contactelectronicmailaddress varchar(255) default NULL,
  wms_mb_getcapabilities_doc text,
  wms_owner int(11) default NULL,
  wms_timestamp int(11) default NULL,
  wms_supportsld tinyint(1) default NULL,
  wms_userlayer tinyint(1) default NULL,
  wms_userstyle tinyint(1) default NULL,
  wms_remotewfs tinyint(1) default NULL,
  PRIMARY KEY  (wms_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'wms'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'wms_format'
-- 

CREATE TABLE IF NOT EXISTS wms_format (
  fkey_wms_id int(11) NOT NULL default '0',
  data_type varchar(50) NOT NULL default '',
  data_format varchar(100) NOT NULL default '',
  PRIMARY KEY  (fkey_wms_id,data_type,data_format),
  KEY wms_index (fkey_wms_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'wms_format'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'wms_md_topic_category'
-- 

CREATE TABLE IF NOT EXISTS wms_md_topic_category (
  fkey_wms_id int(11) NOT NULL,
  fkey_md_topic_category_id int(11) NOT NULL,
  PRIMARY KEY  (fkey_wms_id,fkey_md_topic_category_id),
  KEY wms_md_topic_category_fkey_md_topic_category_id_fkey (fkey_md_topic_category_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'wms_md_topic_category'
-- 


-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle 'wms_srs'
-- 

CREATE TABLE IF NOT EXISTS wms_srs (
  fkey_wms_id int(11) NOT NULL default '0',
  wms_srs varchar(50) NOT NULL default '',
  PRIMARY KEY  (fkey_wms_id,wms_srs),
  KEY wms_index (fkey_wms_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- 
-- Daten für Tabelle 'wms_srs'
-- 


-- 
-- Constraints der exportierten Tabellen
-- 

-- 
-- Constraints der Tabelle `gui_element`
-- 
ALTER TABLE `gui_element`
  ADD CONSTRAINT gui_element_ibfk_1 FOREIGN KEY (fkey_gui_id) REFERENCES gui (gui_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `gui_element_vars`
-- 
ALTER TABLE `gui_element_vars`
  ADD CONSTRAINT gui_element_vars_ibfk_1 FOREIGN KEY (fkey_gui_id, fkey_e_id) REFERENCES gui_element (fkey_gui_id, e_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `gui_layer`
-- 
ALTER TABLE `gui_layer`
  ADD CONSTRAINT gui_layer_ibfk_3 FOREIGN KEY (fkey_gui_id) REFERENCES gui (gui_id) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT gui_layer_ibfk_4 FOREIGN KEY (fkey_layer_id) REFERENCES layer (layer_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `gui_mb_group`
-- 
ALTER TABLE `gui_mb_group`
  ADD CONSTRAINT gui_mb_group_ibfk_1 FOREIGN KEY (fkey_gui_id) REFERENCES gui (gui_id) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT gui_mb_group_ibfk_2 FOREIGN KEY (fkey_mb_group_id) REFERENCES mb_group (mb_group_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `gui_mb_user`
-- 
ALTER TABLE `gui_mb_user`
  ADD CONSTRAINT gui_mb_user_ibfk_1 FOREIGN KEY (fkey_gui_id) REFERENCES gui (gui_id) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT gui_mb_user_ibfk_2 FOREIGN KEY (fkey_mb_user_id) REFERENCES mb_user (mb_user_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `gui_treegde`
-- 
ALTER TABLE `gui_treegde`
  ADD CONSTRAINT gui_treegde_ibfk_1 FOREIGN KEY (fkey_gui_id) REFERENCES gui (gui_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `gui_wfs`
-- 
ALTER TABLE `gui_wfs`
  ADD CONSTRAINT gui_wfs_ibfk_1 FOREIGN KEY (fkey_gui_id) REFERENCES gui (gui_id) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT gui_wfs_ibfk_2 FOREIGN KEY (fkey_wfs_id) REFERENCES wfs (wfs_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `gui_wms`
-- 
ALTER TABLE `gui_wms`
  ADD CONSTRAINT gui_wms_ibfk_3 FOREIGN KEY (fkey_gui_id) REFERENCES gui (gui_id) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT gui_wms_ibfk_4 FOREIGN KEY (fkey_wms_id) REFERENCES wms (wms_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `layer`
-- 
ALTER TABLE `layer`
  ADD CONSTRAINT layer_ibfk_1 FOREIGN KEY (fkey_wms_id) REFERENCES wms (wms_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `layer_epsg`
-- 
ALTER TABLE `layer_epsg`
  ADD CONSTRAINT layer_epsg_ibfk_1 FOREIGN KEY (fkey_layer_id) REFERENCES layer (layer_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `layer_keyword`
-- 
ALTER TABLE `layer_keyword`
  ADD CONSTRAINT fkey_keyword_id_fkey_layer_id FOREIGN KEY (fkey_keyword_id) REFERENCES keyword (keyword_id),
  ADD CONSTRAINT fkey_layer_id_fkey_keyword_id FOREIGN KEY (fkey_layer_id) REFERENCES layer (layer_id);

-- 
-- Constraints der Tabelle `layer_style`
-- 
ALTER TABLE `layer_style`
  ADD CONSTRAINT layer_style_ibfk_1 FOREIGN KEY (fkey_layer_id) REFERENCES layer (layer_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `mb_monitor`
-- 
ALTER TABLE `mb_monitor`
  ADD CONSTRAINT mb_monitor_ibfk_1 FOREIGN KEY (fkey_wms_id) REFERENCES wms (wms_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `mb_user_mb_group`
-- 
ALTER TABLE `mb_user_mb_group`
  ADD CONSTRAINT fkey_mb_user_mb_group_mb_use_id FOREIGN KEY (fkey_mb_user_id) REFERENCES mb_user (mb_user_id) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT mb_user_mb_group_ibfk_1 FOREIGN KEY (fkey_mb_group_id) REFERENCES mb_group (mb_group_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `mb_user_wmc`
-- 
ALTER TABLE `mb_user_wmc`
  ADD CONSTRAINT mb_user_wmc_ibfk_1 FOREIGN KEY (fkey_user_id) REFERENCES mb_user (mb_user_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `sld_user_layer`
-- 
ALTER TABLE `sld_user_layer`
  ADD CONSTRAINT sld_user_layer_ibfk1 FOREIGN KEY (fkey_mb_user_id) REFERENCES mb_user (mb_user_id) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT sld_user_layer_ibfk2 FOREIGN KEY (fkey_layer_id) REFERENCES layer (layer_id) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT sld_user_layer_ibfk3 FOREIGN KEY (fkey_gui_id) REFERENCES gui (gui_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `wfs_conf`
-- 
ALTER TABLE `wfs_conf`
  ADD CONSTRAINT wfs_conf_ibfk_1 FOREIGN KEY (fkey_wfs_id) REFERENCES wfs (wfs_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `wfs_conf_element`
-- 
ALTER TABLE `wfs_conf_element`
  ADD CONSTRAINT wfs_conf_element_ibfk_1 FOREIGN KEY (fkey_wfs_conf_id) REFERENCES wfs_conf (wfs_conf_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `wfs_element`
-- 
ALTER TABLE `wfs_element`
  ADD CONSTRAINT wfs_element_ibfk_1 FOREIGN KEY (fkey_featuretype_id) REFERENCES wfs_featuretype (featuretype_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `wfs_featuretype`
-- 
ALTER TABLE `wfs_featuretype`
  ADD CONSTRAINT wfs_featuretype_ibfk_1 FOREIGN KEY (fkey_wfs_id) REFERENCES wfs (wfs_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `wfs_featuretype_namespace`
-- 
ALTER TABLE `wfs_featuretype_namespace`
  ADD CONSTRAINT wfs_featuretype_namespace_ibfk_1 FOREIGN KEY (fkey_wfs_id) REFERENCES wfs (wfs_id) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT wfs_featuretype_namespace_ibfk_2 FOREIGN KEY (fkey_featuretype_id) REFERENCES wfs_featuretype (featuretype_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `wms_format`
-- 
ALTER TABLE `wms_format`
  ADD CONSTRAINT wms_format_ibfk_1 FOREIGN KEY (fkey_wms_id) REFERENCES wms (wms_id) ON DELETE CASCADE ON UPDATE CASCADE;

-- 
-- Constraints der Tabelle `wms_md_topic_category`
-- 
ALTER TABLE `wms_md_topic_category`
  ADD CONSTRAINT wms_md_topic_category_fkey_md_topic_category_id_fkey FOREIGN KEY (fkey_md_topic_category_id) REFERENCES md_topic_category (md_topic_category_id),
  ADD CONSTRAINT wms_md_topic_category_fkey_wms_id_fkey FOREIGN KEY (fkey_wms_id) REFERENCES wms (wms_id);

-- 
-- Constraints der Tabelle `wms_srs`
-- 
ALTER TABLE `wms_srs`
  ADD CONSTRAINT wms_srs_ibfk_1 FOREIGN KEY (fkey_wms_id) REFERENCES wms (wms_id) ON DELETE CASCADE ON UPDATE CASCADE;

  
  
  
  
ALTER TABLE gui_element MODIFY e_js_file character varying(255);
ALTER TABLE gui_element MODIFY e_mb_mod character varying(255);
ALTER TABLE wms MODIFY fees text;
ALTER TABLE wms CHANGE COLUMN wms_mb_getcapabilities_doc wms_mb_getcapabilities_doc text;


ALTER TABLE `wfs_conf`
    ADD CONSTRAINT wfs_conf_ibfk_2 FOREIGN KEY (fkey_featuretype_id) REFERENCES wfs_featuretype(featuretype_id) ON UPDATE CASCADE ON DELETE CASCADE;