CREATE TABLE EMFLIB_COVER
(
ID NUMBER(22,0) NOT NULL,
ECONT_FEAT_ID NUMBER(22, 0),
COLORED VARCHAR2(80),
ECONTAINER_ID NUMBER(22,0)
)
;

CREATE TABLE EMFLIB_LIBRARY
(
ID NUMBER(22,0) NOT NULL,
NAME VARCHAR2(80) NOT NULL
)
;

CREATE TABLE EMFLIB_LIBRARY_BOOK_MAP
(
KEY VARCHAR(80) NOT NULL,
BOOK_ID NUMBER(22,0) NOT NULL,
LIBRARY_ID NUMBER(22,0) NOT NULL,
ECONT_FEAT_ID NUMBER(22, 0)
)
;

CREATE TABLE EMFLIB_BOOK
(
ID NUMBER(22,0) NOT NULL,
AUTHOR_ID NUMBER(22,0),
CATEGORY VARCHAR2(80),
ECONT_FEAT_ID NUMBER(22, 0),
LIBRARY_NAME VARCHAR2(80),
PAGES NUMBER(22, 0),
TITLE VARCHAR2(80) NOT NULL,
TRANSLATOR_ID NUMBER(22,0)
)
;

CREATE TABLE EMFLIB_WRITER
(
ID NUMBER(22,0) NOT NULL,
ECONT_FEAT_ID NUMBER(22, 0),
ECONTAINER_ID NUMBER(22,0),
NAME VARCHAR2(80) NOT NULL,
ADDRESS_ID NUMBER(22,0)
)
;

CREATE TABLE EMFLIB_PUBLISHER
(
ID NUMBER(22,0) NOT NULL,
NAME VARCHAR2(80) NOT NULL
)
;

CREATE TABLE EMFLIB_WRITER_PUBLISHER
(
WRITER_ID NUMBER(22,0) NOT NULL,
PUBLISHER_ID NUMBER(22,0) NOT NULL
)
;

CREATE TABLE EMFLIB_ADDRESS
(
ID NUMBER(22,0) NOT NULL,
TOWN VARCHAR2(80) NOT NULL,
ECONT_FEAT_ID NUMBER(22, 0)
)
;

CREATE TABLE EMFLIB_STYLE
(
ID NUMBER(22,0) NOT NULL,
NAME VARCHAR2(80) NOT NULL
)
;

CREATE TABLE EMFLIB_BOOK_STYLE_MAP
(
KEY VARCHAR(80) NOT NULL,
BOOK_ID NUMBER(22,0) NOT NULL,
STYLE_ID NUMBER(22,0) NOT NULL,
ECONT_FEAT_ID NUMBER(22, 0)
)
;

CREATE TABLE EMFLIB_TRANSLATOR
(
ID NUMBER(22,0) NOT NULL,
NAME VARCHAR2(80) NOT NULL,
LOCATION VARCHAR2(80)
)
;

CREATE TABLE EMFLIB_TYPEWRITER
(
ID NUMBER(22,0) NOT NULL,
MAKER VARCHAR2(80) NOT NULL,
TYPE VARCHAR2(80)
)
;

CREATE TABLE EMFLIB_WRITER_TYPEWRITER
(
WRITER_ID NUMBER(22,0) NOT NULL,
TYPEWRITER_ID NUMBER(22,0) NOT NULL
)
;

ALTER TABLE EMFLIB_ADDRESS
ADD CONSTRAINT EMFLIB_ADDRESS_PK PRIMARY KEY
(
ID
)
 ENABLE
;

ALTER TABLE EMFLIB_LIBRARY
ADD CONSTRAINT EMFLIB_LIBRARY_PK PRIMARY KEY
(
ID
)
 ENABLE
;

ALTER TABLE EMFLIB_LIBRARY_BOOK_MAP
ADD CONSTRAINT EMFLIB_LIBRARY_BOOK_MAP_PK PRIMARY KEY
(
KEY,
LIBRARY_ID
)
 ENABLE
;

ALTER TABLE EMFLIB_BOOK
ADD CONSTRAINT EMFLIB_BOOK_PK PRIMARY KEY
(
ID
)
 ENABLE
;

ALTER TABLE EMFLIB_COVER
ADD CONSTRAINT EMFLIB_COVER_PK PRIMARY KEY
(
ID
)
 ENABLE
;

ALTER TABLE EMFLIB_COVER
ADD CONSTRAINT EMFLIB_COVER_BOOK_REF FOREIGN KEY
(
ECONTAINER_ID
)
REFERENCES EMFLIB_BOOK
(
ID
) ENABLE
;

ALTER TABLE EMFLIB_WRITER
ADD CONSTRAINT EMFLIB_WRITER_PK PRIMARY KEY
(
ID
)
 ENABLE
;

ALTER TABLE EMFLIB_PUBLISHER
ADD CONSTRAINT EMFLIB_PUBLISHER_PK PRIMARY KEY
(
ID
)
 ENABLE
;

ALTER TABLE EMFLIB_WRITER_PUBLISHER
ADD CONSTRAINT EMFLIB_WRITER_PUBLISHER_PK PRIMARY KEY
(
WRITER_ID,
PUBLISHER_ID
)
 ENABLE
;

ALTER TABLE EMFLIB_STYLE
ADD CONSTRAINT EMFLIB_STYLE_PK PRIMARY KEY
(
ID
)
 ENABLE
;

ALTER TABLE EMFLIB_BOOK_STYLE_MAP
ADD CONSTRAINT EMFLIB_BOOK_STYLE_MAP_PK PRIMARY KEY
(
KEY,
BOOK_ID
)
 ENABLE
;

ALTER TABLE EMFLIB_TRANSLATOR
ADD CONSTRAINT TRANSLATOR_PK PRIMARY KEY
(
ID
)
 ENABLE
;

ALTER TABLE EMFLIB_TYPEWRITER
ADD CONSTRAINT EMFLIB_TYPEWRITER_PK PRIMARY KEY
(
ID
)
 ENABLE
;

ALTER TABLE EMFLIB_WRITER_TYPEWRITER
ADD CONSTRAINT EMFLIB_WRITER_TYPEWRITER_PK PRIMARY KEY
(
WRITER_ID,
TYPEWRITER_ID
)
 ENABLE
;

ALTER TABLE EMFLIB_LIBRARY_BOOK_MAP
ADD CONSTRAINT EMFLIB_LIBRARY_BOOK_BOOK_REF FOREIGN KEY
(
BOOK_ID
)
REFERENCES EMFLIB_BOOK
(
ID
) ENABLE
;

ALTER TABLE EMFLIB_LIBRARY_BOOK_MAP
ADD CONSTRAINT EMFLIB_LIBRARY_BOOK_EMFLIB_REF FOREIGN KEY
(
LIBRARY_ID
)
REFERENCES EMFLIB_LIBRARY
(
ID
) ENABLE
;

ALTER TABLE EMFLIB_BOOK
ADD CONSTRAINT EMFLIB_BOOK_WRITER FOREIGN KEY
(
AUTHOR_ID
)
REFERENCES EMFLIB_WRITER
(
ID
) ENABLE
;

ALTER TABLE EMFLIB_BOOK
ADD CONSTRAINT EMFLIB_BOOK_TRANSLATOR FOREIGN KEY
(
TRANSLATOR_ID
)
REFERENCES EMFLIB_TRANSLATOR
(
ID
) ENABLE
;

ALTER TABLE EMFLIB_WRITER
ADD CONSTRAINT EMFLIB_WRITER_ADDRESS_FK FOREIGN KEY
(
ADDRESS_ID
)
REFERENCES EMFLIB_ADDRESS
(
ID
) ENABLE
;

ALTER TABLE EMFLIB_WRITER
ADD CONSTRAINT EMFLIB_WRITER_LIBRARY_FK FOREIGN KEY
(
ECONTAINER_ID
)
REFERENCES EMFLIB_LIBRARY
(
ID
) ENABLE
;

ALTER TABLE EMFLIB_WRITER_PUBLISHER
ADD CONSTRAINT EMFLIB_TO_PUBLISHER_FK FOREIGN KEY
(
PUBLISHER_ID
)
REFERENCES EMFLIB_PUBLISHER
(
ID
) ENABLE
;

ALTER TABLE EMFLIB_WRITER_PUBLISHER
ADD CONSTRAINT EMFLIB_TO_WRITER_FK FOREIGN KEY
(
WRITER_ID
)
REFERENCES EMFLIB_WRITER
(
ID
) ENABLE
;

ALTER TABLE EMFLIB_BOOK_STYLE_MAP
ADD CONSTRAINT EMFLIB_BOOK_STYLE_BOOK_FK FOREIGN KEY
(
BOOK_ID
)
REFERENCES EMFLIB_BOOK
(
ID
) ENABLE
;

ALTER TABLE EMFLIB_BOOK_STYLE_MAP
ADD CONSTRAINT EMFLIB_BOOK_STYLE_STYLE_FK FOREIGN KEY
(
STYLE_ID
)
REFERENCES EMFLIB_STYLE
(
ID
) ENABLE
;

ALTER TABLE EMFLIB_WRITER_TYPEWRITER
ADD CONSTRAINT EMFLIB_TW_TO_WRITER_FK FOREIGN KEY
(
WRITER_ID
)
REFERENCES EMFLIB_WRITER
(
ID
) ENABLE
;

ALTER TABLE EMFLIB_WRITER_TYPEWRITER
ADD CONSTRAINT EMFLIB_TW_TO_TYPEWRITER_FK FOREIGN KEY
(
TYPEWRITER_ID
)
REFERENCES EMFLIB_TYPEWRITER
(
ID
) ENABLE
;

CREATE TABLE SEQUENCE
( "SEQ_NAME" VARCHAR2(50 BYTE), 
 "SEQ_COUNT" NUMBER(38,0)
)

