--
-- Create Schema Script 
--   Database Version   : 10.1.0.2.0 
--   TOAD Version       : 9.0.1.8 
--   DB Connect String  : ORCL 
--   Schema             : WIFI 
--   Script Created by  : SYSTEM 
--   Script Created at  : 07.09.2007 10:39:17 
--   Physical Location  :  
--   Notes              :  
--

-- Object Counts: 
--   Indexes: 5         Columns: 6          
--   Sequences: 1 
--   Tables: 4          Columns: 10         Constraints: 7      


CREATE SEQUENCE SEQ
  START WITH 41
  MAXVALUE 999999999999999999999999999
  MINVALUE 1
  NOCYCLE
  CACHE 20
  NOORDER;


CREATE TABLE TST_VERMIETER
(
  VRM_ID    NUMBER                              NOT NULL,
  VRM_NAME  VARCHAR2(100 BYTE)
)
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE TABLE TST_FAHRZEUGE
(
  FHZ_ID      NUMBER                            NOT NULL,
  FHZ_NAME    VARCHAR2(100 BYTE),
  FHZ_VRM_ID  NUMBER
)
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE TABLE TST_EXTRAS
(
  EXT_ID    NUMBER                              NOT NULL,
  EXT_NAME  VARCHAR2(100 BYTE)
)
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE TABLE TST_FHZ_EXT_INT
(
  FEI_ID      NUMBER,
  FEI_FHZ_ID  NUMBER,
  FEI_EXT_ID  NUMBER
)
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX TST_VRM_PK ON TST_VERMIETER
(VRM_ID)
LOGGING
NOPARALLEL;


CREATE UNIQUE INDEX TST_FHZ_ID_PK ON TST_FAHRZEUGE
(FHZ_ID)
LOGGING
NOPARALLEL;


CREATE UNIQUE INDEX TST_EXT_ID_PK ON TST_EXTRAS
(EXT_ID)
LOGGING
NOPARALLEL;


CREATE UNIQUE INDEX TST_FEI_ID_PK ON TST_FHZ_EXT_INT
(FEI_ID)
LOGGING
NOPARALLEL;


CREATE UNIQUE INDEX TST_FHZ_ID_EXT_ID_UK ON TST_FHZ_EXT_INT
(FEI_FHZ_ID, FEI_EXT_ID)
LOGGING
NOPARALLEL;


ALTER TABLE TST_VERMIETER ADD (
  CONSTRAINT TST_VRM_ID_PK
 PRIMARY KEY
 (VRM_ID));

ALTER TABLE TST_FAHRZEUGE ADD (
  CONSTRAINT TST_FHZ_ID_PK
 PRIMARY KEY
 (FHZ_ID));

ALTER TABLE TST_EXTRAS ADD (
  CONSTRAINT TST_EXT_ID_PK
 PRIMARY KEY
 (EXT_ID));

ALTER TABLE TST_FHZ_EXT_INT ADD (
  CONSTRAINT TST_FEI_ID_PK
 PRIMARY KEY
 (FEI_ID));

ALTER TABLE TST_FAHRZEUGE ADD (
  CONSTRAINT TST_FHZ_VRM_ID_FK 
 FOREIGN KEY (FHZ_VRM_ID) 
 REFERENCES TST_VERMIETER (VRM_ID));

ALTER TABLE TST_FHZ_EXT_INT ADD (
  CONSTRAINT TST_FEI_FHZ_ID_FK 
 FOREIGN KEY (FEI_FHZ_ID) 
 REFERENCES TST_FAHRZEUGE (FHZ_ID),
  CONSTRAINT TST_FEI_EXT_ID_FK 
 FOREIGN KEY (FEI_EXT_ID) 
 REFERENCES TST_EXTRAS (EXT_ID));

