CREATE TABLE import_fej
(
  kod serial,
  file_name character varying(300),
  comment character varying(300),
  betoltve smallint,
  CONSTRAINT import_fej_pkey PRIMARY KEY (kod)
)
WITHOUT OIDS;

CREATE TABLE import
(
  kod serial,
  fej_kod integer,
  fajl_oszlop_neve character varying(150),
  tetel_mezo character varying(150),
  azonosito smallint DEFAULT 0,
  oszlop_szama smallint,
  torolve smallint DEFAULT 0,
  CONSTRAINT import_pkey PRIMARY KEY (kod)
)
WITHOUT OIDS;

CREATE TABLE import_tetel
(
  kod serial,
  lang_0000040e character varying(500) NOT NULL DEFAULT '',
  lang_00000409 character varying(500) DEFAULT '',
  lang_00000407 character varying(500) DEFAULT '',
  sor2 character varying(100) DEFAULT '',
  sor3 character varying(100) DEFAULT '',
  nyitas date DEFAULT '2005-01-01',
  kapcsolt_fokonyviszam character varying(20) DEFAULT '',
  vonalkod character varying(30) DEFAULT '',
  tetel_tipus integer NOT NULL,
  afa_kulcs integer NOT NULL,
  kompenzacio_mezogazd integer DEFAULT 0,
  tetel_azonosito_kod character varying(20) NOT NULL DEFAULT '',
  minimum_keszlet double precision DEFAULT (0),
  maximum_keszlet double precision DEFAULT (0),
  engedely_koteles integer NOT NULL DEFAULT 0,
  besorolas character varying(10) DEFAULT '',
  mennyisegi_egyseg integer NOT NULL,
  pontertek integer DEFAULT 0,
  haszonkulcs double precision DEFAULT (0),
  minimum_haszonkulcs double precision DEFAULT (0),
  egy_egyseg_sulya double precision DEFAULT (0),
  megjegyzes character varying(5000) DEFAULT '',
  tetel_csoport_kod integer NOT NULL DEFAULT 0,
  jellemzo_beszallito integer DEFAULT 0,
  garancia integer DEFAULT 0,
  tizedesjegy integer DEFAULT 0,
  arlistaban integer DEFAULT 0,
  akcios integer DEFAULT 0,
  utolsobeszerzesiar double precision DEFAULT (0),
  m_userid character varying(20) DEFAULT '',
  m_date date DEFAULT '2005-01-01',
  m_time time without time zone DEFAULT '00:00:00',
  c_userid character varying(20) DEFAULT '',
  c_date date DEFAULT '2005-01-01',
  c_time time without time zone DEFAULT '00:00:00',
  hasznalatban integer,
  fajta1 integer DEFAULT 0,
  fajta2 integer DEFAULT 0,
  fajta3 integer DEFAULT 0,
  sor4 character varying(100) DEFAULT '',
  webboltban integer DEFAULT 0,
  leiras character varying(5000),
  forditottan_adozhat smallint DEFAULT 0,
  egyedi integer DEFAULT 0,
  szoveges_kod character varying(40) DEFAULT '',
  fobizonylaton_nem_latszik smallint DEFAULT 0,
  utolsobeszerzesiardatuma date,
  webboltban_akcios smallint DEFAULT 0,
  webboltban_kiemelt smallint DEFAULT 0,
  webboltban_latogatas_szama integer DEFAULT 0,
  webboltban_kosarbarakas_szama integer DEFAULT 0,
  webboltban_megrendeles_szama integer DEFAULT 0,
  fajta4 integer DEFAULT 0,
  fajta5 integer DEFAULT 0,
  fajta6 integer DEFAULT 0,
  zaradek_lang_0000040e character varying(500) DEFAULT '',
  zaradek_lang_00000409 character varying(500) DEFAULT '',
  zaradek_lang_00000407 character varying(500) DEFAULT '',
  szigoruszamadasu_nyomtatvany smallint DEFAULT 0,
  kozvetitett_szolglatatas smallint,
  tetel_raktar_fifo_lock_date date,
  lang_0000040c character varying(500) DEFAULT '',
  lang_00000419 character varying(500) DEFAULT '',
  zaradek_lang_0000040c character varying(500) DEFAULT '',
  zaradek_lang_00000419 character varying(500) DEFAULT '',
  csomagolasi_egyseg character varying(15),
  webboltban_akcio_szazalek numeric(14,2),
  webbolt_nev character varying(500),
  fej_kod integer,
  tetel_egysegar_netto_alapertelmezett_egysegar numeric(12,2),
  tetel_egysegar_brutto_alapertelmezett_egysegar numeric(12,2),
  CONSTRAINT import_tetel_pkey PRIMARY KEY (kod),
  CONSTRAINT tetel_fk1 FOREIGN KEY (afa_kulcs)
      REFERENCES public.afa_kulcs (kod) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT tetel_fk2 FOREIGN KEY (mennyisegi_egyseg)
      REFERENCES public.mennyisegi_egyseg (kod) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT tetel_fk3 FOREIGN KEY (fajta1)
      REFERENCES public.tetel_fajtak (kod) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT tetel_fk4 FOREIGN KEY (fajta2)
      REFERENCES public.tetel_fajtak (kod) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT tetel_fk5 FOREIGN KEY (fajta3)
      REFERENCES public.tetel_fajtak (kod) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT tetel_fk6 FOREIGN KEY (jellemzo_beszallito)
      REFERENCES public.partner (kod) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT tetel_ch1 CHECK (tetel_tipus = 0 OR tetel_tipus = 1 OR tetel_tipus = 2 OR tetel_tipus = 3 OR tetel_tipus = 4 OR tetel_tipus = 5 OR tetel_tipus = 6 OR tetel_tipus = 7 OR tetel_tipus = 8 OR tetel_tipus = 9 OR tetel_tipus = 10)
)
WITHOUT OIDS;