
-----------------------------------------------------------------------------
-- FOLDER
-----------------------------------------------------------------------------

CREATE TABLE FOLDER
(
    FOLDER_ID NUMBER(10,0) NOT NULL,
    PARENT_ID NUMBER(10,0),
    PATH VARCHAR2(240) NOT NULL,
    NAME VARCHAR2(80) NOT NULL,
    TITLE VARCHAR2(100),
    SHORT_TITLE VARCHAR2(40),
    IS_HIDDEN NUMBER(1,0) NOT NULL,
    SKIN VARCHAR2(80),
    DEFAULT_LAYOUT_DECORATOR VARCHAR2(80),
    DEFAULT_PORTLET_DECORATOR VARCHAR2(80),
    DEFAULT_PAGE_NAME VARCHAR2(80),
    SUBSITE VARCHAR2(40),
    USER_PRINCIPAL VARCHAR2(40),
    ROLE_PRINCIPAL VARCHAR2(40),
    GROUP_PRINCIPAL VARCHAR2(40),
    MEDIATYPE VARCHAR2(15),
    LOCALE VARCHAR2(20),
    EXT_ATTR_NAME VARCHAR2(15),
    EXT_ATTR_VALUE VARCHAR2(40),
    OWNER_PRINCIPAL VARCHAR2(40),
    CONSTRAINT UN_FOLDER_1 UNIQUE (PATH)
);

ALTER TABLE FOLDER
    ADD CONSTRAINT FOLDER_PK
PRIMARY KEY (FOLDER_ID);

CREATE INDEX IX_FOLDER_1 ON FOLDER (PARENT_ID);





-----------------------------------------------------------------------------
-- FOLDER_METADATA
-----------------------------------------------------------------------------

CREATE TABLE FOLDER_METADATA
(
    METADATA_ID NUMBER(10,0) NOT NULL,
    FOLDER_ID NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(15) NOT NULL,
    LOCALE VARCHAR2(20) NOT NULL,
    VALUE VARCHAR2(100) NOT NULL,
    CONSTRAINT UN_FOLDER_METADATA_1 UNIQUE (FOLDER_ID, NAME, LOCALE, VALUE)
);

ALTER TABLE FOLDER_METADATA
    ADD CONSTRAINT FOLDER_METADATA_PK
PRIMARY KEY (METADATA_ID);

CREATE INDEX IX_FOLDER_METADATA_1 ON FOLDER_METADATA (FOLDER_ID);





-----------------------------------------------------------------------------
-- FOLDER_CONSTRAINT
-----------------------------------------------------------------------------

CREATE TABLE FOLDER_CONSTRAINT
(
    CONSTRAINT_ID NUMBER(10,0) NOT NULL,
    FOLDER_ID NUMBER(10,0) NOT NULL,
    APPLY_ORDER NUMBER(10,0) NOT NULL,
    USER_PRINCIPALS_ACL VARCHAR2(120),
    ROLE_PRINCIPALS_ACL VARCHAR2(120),
    GROUP_PRINCIPALS_ACL VARCHAR2(120),
    PERMISSIONS_ACL VARCHAR2(120)
);

ALTER TABLE FOLDER_CONSTRAINT
    ADD CONSTRAINT FOLDER_CONSTRAINT_PK
PRIMARY KEY (CONSTRAINT_ID);

CREATE INDEX IX_FOLDER_CONSTRAINT_1 ON FOLDER_CONSTRAINT (FOLDER_ID);





-----------------------------------------------------------------------------
-- FOLDER_CONSTRAINTS_REF
-----------------------------------------------------------------------------

CREATE TABLE FOLDER_CONSTRAINTS_REF
(
    CONSTRAINTS_REF_ID NUMBER(10,0) NOT NULL,
    FOLDER_ID NUMBER(10,0) NOT NULL,
    APPLY_ORDER NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(40) NOT NULL,
    CONSTRAINT UN_FOLDER_CONSTRAINTS_REF_1 UNIQUE (FOLDER_ID, NAME)
);

ALTER TABLE FOLDER_CONSTRAINTS_REF
    ADD CONSTRAINT FOLDER_CONSTRAINTS_REF_PK
PRIMARY KEY (CONSTRAINTS_REF_ID);

CREATE INDEX IX_FOLDER_CONSTRAINTS_REF_1 ON FOLDER_CONSTRAINTS_REF (FOLDER_ID);





-----------------------------------------------------------------------------
-- FOLDER_ORDER
-----------------------------------------------------------------------------

CREATE TABLE FOLDER_ORDER
(
    ORDER_ID NUMBER(10,0) NOT NULL,
    FOLDER_ID NUMBER(10,0) NOT NULL,
    SORT_ORDER NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(80) NOT NULL,
    CONSTRAINT UN_FOLDER_ORDER_1 UNIQUE (FOLDER_ID, NAME)
);

ALTER TABLE FOLDER_ORDER
    ADD CONSTRAINT FOLDER_ORDER_PK
PRIMARY KEY (ORDER_ID);

CREATE INDEX IX_FOLDER_ORDER_1 ON FOLDER_ORDER (FOLDER_ID);





-----------------------------------------------------------------------------
-- FOLDER_MENU
-----------------------------------------------------------------------------

CREATE TABLE FOLDER_MENU
(
    MENU_ID NUMBER(10,0) NOT NULL,
    CLASS_NAME VARCHAR2(100) NOT NULL,
    PARENT_ID NUMBER(10,0),
    FOLDER_ID NUMBER(10,0),
    ELEMENT_ORDER NUMBER(10,0),
    NAME VARCHAR2(100),
    TITLE VARCHAR2(100),
    SHORT_TITLE VARCHAR2(40),
    TEXT VARCHAR2(100),
    OPTIONS VARCHAR2(255),
    DEPTH NUMBER(10,0),
    IS_PATHS NUMBER(1,0),
    IS_REGEXP NUMBER(1,0),
    PROFILE VARCHAR2(80),
    OPTIONS_ORDER VARCHAR2(255),
    SKIN VARCHAR2(80),
    IS_NEST NUMBER(1,0)
);

ALTER TABLE FOLDER_MENU
    ADD CONSTRAINT FOLDER_MENU_PK
PRIMARY KEY (MENU_ID);

CREATE INDEX IX_FOLDER_MENU_1 ON FOLDER_MENU (PARENT_ID);
CREATE INDEX UN_FOLDER_MENU_1 ON FOLDER_MENU (FOLDER_ID, NAME);





-----------------------------------------------------------------------------
-- FOLDER_MENU_METADATA
-----------------------------------------------------------------------------

CREATE TABLE FOLDER_MENU_METADATA
(
    METADATA_ID NUMBER(10,0) NOT NULL,
    MENU_ID NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(15) NOT NULL,
    LOCALE VARCHAR2(20) NOT NULL,
    VALUE VARCHAR2(100) NOT NULL,
    CONSTRAINT UN_FOLDER_MENU_METADATA_1 UNIQUE (MENU_ID, NAME, LOCALE, VALUE)
);

ALTER TABLE FOLDER_MENU_METADATA
    ADD CONSTRAINT FOLDER_MENU_METADATA_PK
PRIMARY KEY (METADATA_ID);

CREATE INDEX IX_FOLDER_MENU_METADATA_1 ON FOLDER_MENU_METADATA (MENU_ID);





-----------------------------------------------------------------------------
-- PAGE
-----------------------------------------------------------------------------

CREATE TABLE PAGE
(
    PAGE_ID NUMBER(10,0) NOT NULL,
    PARENT_ID NUMBER(10,0) NOT NULL,
    PATH VARCHAR2(240) NOT NULL,
    NAME VARCHAR2(80) NOT NULL,
    VERSION VARCHAR2(40),
    TITLE VARCHAR2(100),
    SHORT_TITLE VARCHAR2(40),
    IS_HIDDEN NUMBER(1,0) NOT NULL,
    SKIN VARCHAR2(80),
    DEFAULT_LAYOUT_DECORATOR VARCHAR2(80),
    DEFAULT_PORTLET_DECORATOR VARCHAR2(80),
    SUBSITE VARCHAR2(40),
    USER_PRINCIPAL VARCHAR2(40),
    ROLE_PRINCIPAL VARCHAR2(40),
    GROUP_PRINCIPAL VARCHAR2(40),
    MEDIATYPE VARCHAR2(15),
    LOCALE VARCHAR2(20),
    EXT_ATTR_NAME VARCHAR2(15),
    EXT_ATTR_VALUE VARCHAR2(40),
    OWNER_PRINCIPAL VARCHAR2(40),
    CONSTRAINT UN_PAGE_1 UNIQUE (PATH)
);

ALTER TABLE PAGE
    ADD CONSTRAINT PAGE_PK
PRIMARY KEY (PAGE_ID);

CREATE INDEX IX_PAGE_1 ON PAGE (PARENT_ID);





-----------------------------------------------------------------------------
-- PAGE_METADATA
-----------------------------------------------------------------------------

CREATE TABLE PAGE_METADATA
(
    METADATA_ID NUMBER(10,0) NOT NULL,
    PAGE_ID NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(15) NOT NULL,
    LOCALE VARCHAR2(20) NOT NULL,
    VALUE VARCHAR2(100) NOT NULL,
    CONSTRAINT UN_PAGE_METADATA_1 UNIQUE (PAGE_ID, NAME, LOCALE, VALUE)
);

ALTER TABLE PAGE_METADATA
    ADD CONSTRAINT PAGE_METADATA_PK
PRIMARY KEY (METADATA_ID);

CREATE INDEX IX_PAGE_METADATA_1 ON PAGE_METADATA (PAGE_ID);





-----------------------------------------------------------------------------
-- PAGE_CONSTRAINT
-----------------------------------------------------------------------------

CREATE TABLE PAGE_CONSTRAINT
(
    CONSTRAINT_ID NUMBER(10,0) NOT NULL,
    PAGE_ID NUMBER(10,0) NOT NULL,
    APPLY_ORDER NUMBER(10,0) NOT NULL,
    USER_PRINCIPALS_ACL VARCHAR2(120),
    ROLE_PRINCIPALS_ACL VARCHAR2(120),
    GROUP_PRINCIPALS_ACL VARCHAR2(120),
    PERMISSIONS_ACL VARCHAR2(120)
);

ALTER TABLE PAGE_CONSTRAINT
    ADD CONSTRAINT PAGE_CONSTRAINT_PK
PRIMARY KEY (CONSTRAINT_ID);

CREATE INDEX IX_PAGE_CONSTRAINT_1 ON PAGE_CONSTRAINT (PAGE_ID);





-----------------------------------------------------------------------------
-- PAGE_CONSTRAINTS_REF
-----------------------------------------------------------------------------

CREATE TABLE PAGE_CONSTRAINTS_REF
(
    CONSTRAINTS_REF_ID NUMBER(10,0) NOT NULL,
    PAGE_ID NUMBER(10,0) NOT NULL,
    APPLY_ORDER NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(40) NOT NULL,
    CONSTRAINT UN_PAGE_CONSTRAINTS_REF_1 UNIQUE (PAGE_ID, NAME)
);

ALTER TABLE PAGE_CONSTRAINTS_REF
    ADD CONSTRAINT PAGE_CONSTRAINTS_REF_PK
PRIMARY KEY (CONSTRAINTS_REF_ID);

CREATE INDEX IX_PAGE_CONSTRAINTS_REF_1 ON PAGE_CONSTRAINTS_REF (PAGE_ID);





-----------------------------------------------------------------------------
-- PAGE_MENU
-----------------------------------------------------------------------------

CREATE TABLE PAGE_MENU
(
    MENU_ID NUMBER(10,0) NOT NULL,
    CLASS_NAME VARCHAR2(100) NOT NULL,
    PARENT_ID NUMBER(10,0),
    PAGE_ID NUMBER(10,0),
    ELEMENT_ORDER NUMBER(10,0),
    NAME VARCHAR2(100),
    TITLE VARCHAR2(100),
    SHORT_TITLE VARCHAR2(40),
    TEXT VARCHAR2(100),
    OPTIONS VARCHAR2(255),
    DEPTH NUMBER(10,0),
    IS_PATHS NUMBER(1,0),
    IS_REGEXP NUMBER(1,0),
    PROFILE VARCHAR2(80),
    OPTIONS_ORDER VARCHAR2(255),
    SKIN VARCHAR2(80),
    IS_NEST NUMBER(1,0)
);

ALTER TABLE PAGE_MENU
    ADD CONSTRAINT PAGE_MENU_PK
PRIMARY KEY (MENU_ID);

CREATE INDEX IX_PAGE_MENU_1 ON PAGE_MENU (PARENT_ID);
CREATE INDEX UN_PAGE_MENU_1 ON PAGE_MENU (PAGE_ID, NAME);





-----------------------------------------------------------------------------
-- PAGE_MENU_METADATA
-----------------------------------------------------------------------------

CREATE TABLE PAGE_MENU_METADATA
(
    METADATA_ID NUMBER(10,0) NOT NULL,
    MENU_ID NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(15) NOT NULL,
    LOCALE VARCHAR2(20) NOT NULL,
    VALUE VARCHAR2(100) NOT NULL,
    CONSTRAINT UN_PAGE_MENU_METADATA_1 UNIQUE (MENU_ID, NAME, LOCALE, VALUE)
);

ALTER TABLE PAGE_MENU_METADATA
    ADD CONSTRAINT PAGE_MENU_METADATA_PK
PRIMARY KEY (METADATA_ID);

CREATE INDEX IX_PAGE_MENU_METADATA_1 ON PAGE_MENU_METADATA (MENU_ID);





-----------------------------------------------------------------------------
-- FRAGMENT
-----------------------------------------------------------------------------

CREATE TABLE FRAGMENT
(
    FRAGMENT_ID NUMBER(10,0) NOT NULL,
    PARENT_ID NUMBER(10,0),
    PAGE_ID NUMBER(10,0),
    NAME VARCHAR2(100),
    TITLE VARCHAR2(100),
    SHORT_TITLE VARCHAR2(40),
    TYPE VARCHAR2(40),
    SKIN VARCHAR2(80),
    DECORATOR VARCHAR2(80),
    STATE VARCHAR2(10),
    PMODE VARCHAR2(10),
    LAYOUT_ROW NUMBER(10,0),
    LAYOUT_COLUMN NUMBER(10,0),
    LAYOUT_SIZES VARCHAR2(20),
    LAYOUT_X NUMBER,
    LAYOUT_Y NUMBER,
    LAYOUT_Z NUMBER,
    LAYOUT_WIDTH NUMBER,
    LAYOUT_HEIGHT NUMBER,
    EXT_PROP_NAME_1 VARCHAR2(40),
    EXT_PROP_VALUE_1 VARCHAR2(80),
    EXT_PROP_NAME_2 VARCHAR2(40),
    EXT_PROP_VALUE_2 VARCHAR2(80),
    OWNER_PRINCIPAL VARCHAR2(40)
);

ALTER TABLE FRAGMENT
    ADD CONSTRAINT FRAGMENT_PK
PRIMARY KEY (FRAGMENT_ID);

CREATE INDEX IX_FRAGMENT_1 ON FRAGMENT (PARENT_ID);
CREATE INDEX UN_FRAGMENT_1 ON FRAGMENT (PAGE_ID);





-----------------------------------------------------------------------------
-- FRAGMENT_CONSTRAINT
-----------------------------------------------------------------------------

CREATE TABLE FRAGMENT_CONSTRAINT
(
    CONSTRAINT_ID NUMBER(10,0) NOT NULL,
    FRAGMENT_ID NUMBER(10,0) NOT NULL,
    APPLY_ORDER NUMBER(10,0) NOT NULL,
    USER_PRINCIPALS_ACL VARCHAR2(120),
    ROLE_PRINCIPALS_ACL VARCHAR2(120),
    GROUP_PRINCIPALS_ACL VARCHAR2(120),
    PERMISSIONS_ACL VARCHAR2(120)
);

ALTER TABLE FRAGMENT_CONSTRAINT
    ADD CONSTRAINT FRAGMENT_CONSTRAINT_PK
PRIMARY KEY (CONSTRAINT_ID);

CREATE INDEX IX_FRAGMENT_CONSTRAINT_1 ON FRAGMENT_CONSTRAINT (FRAGMENT_ID);





-----------------------------------------------------------------------------
-- FRAGMENT_CONSTRAINTS_REF
-----------------------------------------------------------------------------

CREATE TABLE FRAGMENT_CONSTRAINTS_REF
(
    CONSTRAINTS_REF_ID NUMBER(10,0) NOT NULL,
    FRAGMENT_ID NUMBER(10,0) NOT NULL,
    APPLY_ORDER NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(40) NOT NULL,
    CONSTRAINT UN_FRAGMENT_CONSTRAINTS_REF_1 UNIQUE (FRAGMENT_ID, NAME)
);

ALTER TABLE FRAGMENT_CONSTRAINTS_REF
    ADD CONSTRAINT FRAGMENT_CONSTRAINTS_REF_PK
PRIMARY KEY (CONSTRAINTS_REF_ID);

CREATE INDEX IX_FRAGMENT_CONSTRAINTS_REF_1 ON FRAGMENT_CONSTRAINTS_REF (FRAGMENT_ID);





-----------------------------------------------------------------------------
-- FRAGMENT_PREF
-----------------------------------------------------------------------------

CREATE TABLE FRAGMENT_PREF
(
    PREF_ID NUMBER(10,0) NOT NULL,
    FRAGMENT_ID NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(40) NOT NULL,
    IS_READ_ONLY NUMBER(1,0) NOT NULL,
    CONSTRAINT UN_FRAGMENT_PREF_1 UNIQUE (FRAGMENT_ID, NAME)
);

ALTER TABLE FRAGMENT_PREF
    ADD CONSTRAINT FRAGMENT_PREF_PK
PRIMARY KEY (PREF_ID);

CREATE INDEX IX_FRAGMENT_PREF_1 ON FRAGMENT_PREF (FRAGMENT_ID);





-----------------------------------------------------------------------------
-- FRAGMENT_PREF_VALUE
-----------------------------------------------------------------------------

CREATE TABLE FRAGMENT_PREF_VALUE
(
    PREF_VALUE_ID NUMBER(10,0) NOT NULL,
    PREF_ID NUMBER(10,0) NOT NULL,
    VALUE_ORDER NUMBER(10,0) NOT NULL,
    VALUE VARCHAR2(100) NOT NULL
);

ALTER TABLE FRAGMENT_PREF_VALUE
    ADD CONSTRAINT FRAGMENT_PREF_VALUE_PK
PRIMARY KEY (PREF_VALUE_ID);

CREATE INDEX IX_FRAGMENT_PREF_VALUE_1 ON FRAGMENT_PREF_VALUE (PREF_ID);





-----------------------------------------------------------------------------
-- LINK
-----------------------------------------------------------------------------

CREATE TABLE LINK
(
    LINK_ID NUMBER(10,0) NOT NULL,
    PARENT_ID NUMBER(10,0) NOT NULL,
    PATH VARCHAR2(240) NOT NULL,
    NAME VARCHAR2(80) NOT NULL,
    VERSION VARCHAR2(40),
    TITLE VARCHAR2(100),
    SHORT_TITLE VARCHAR2(40),
    IS_HIDDEN NUMBER(1,0) NOT NULL,
    SKIN VARCHAR2(80),
    TARGET VARCHAR2(80),
    URL VARCHAR2(255),
    SUBSITE VARCHAR2(40),
    USER_PRINCIPAL VARCHAR2(40),
    ROLE_PRINCIPAL VARCHAR2(40),
    GROUP_PRINCIPAL VARCHAR2(40),
    MEDIATYPE VARCHAR2(15),
    LOCALE VARCHAR2(20),
    EXT_ATTR_NAME VARCHAR2(15),
    EXT_ATTR_VALUE VARCHAR2(40),
    OWNER_PRINCIPAL VARCHAR2(40),
    CONSTRAINT UN_LINK_1 UNIQUE (PATH)
);

ALTER TABLE LINK
    ADD CONSTRAINT LINK_PK
PRIMARY KEY (LINK_ID);

CREATE INDEX IX_LINK_1 ON LINK (PARENT_ID);





-----------------------------------------------------------------------------
-- LINK_METADATA
-----------------------------------------------------------------------------

CREATE TABLE LINK_METADATA
(
    METADATA_ID NUMBER(10,0) NOT NULL,
    LINK_ID NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(15) NOT NULL,
    LOCALE VARCHAR2(20) NOT NULL,
    VALUE VARCHAR2(100) NOT NULL,
    CONSTRAINT UN_LINK_METADATA_1 UNIQUE (LINK_ID, NAME, LOCALE, VALUE)
);

ALTER TABLE LINK_METADATA
    ADD CONSTRAINT LINK_METADATA_PK
PRIMARY KEY (METADATA_ID);

CREATE INDEX IX_LINK_METADATA_1 ON LINK_METADATA (LINK_ID);





-----------------------------------------------------------------------------
-- LINK_CONSTRAINT
-----------------------------------------------------------------------------

CREATE TABLE LINK_CONSTRAINT
(
    CONSTRAINT_ID NUMBER(10,0) NOT NULL,
    LINK_ID NUMBER(10,0) NOT NULL,
    APPLY_ORDER NUMBER(10,0) NOT NULL,
    USER_PRINCIPALS_ACL VARCHAR2(120),
    ROLE_PRINCIPALS_ACL VARCHAR2(120),
    GROUP_PRINCIPALS_ACL VARCHAR2(120),
    PERMISSIONS_ACL VARCHAR2(120)
);

ALTER TABLE LINK_CONSTRAINT
    ADD CONSTRAINT LINK_CONSTRAINT_PK
PRIMARY KEY (CONSTRAINT_ID);

CREATE INDEX IX_LINK_CONSTRAINT_1 ON LINK_CONSTRAINT (LINK_ID);





-----------------------------------------------------------------------------
-- LINK_CONSTRAINTS_REF
-----------------------------------------------------------------------------

CREATE TABLE LINK_CONSTRAINTS_REF
(
    CONSTRAINTS_REF_ID NUMBER(10,0) NOT NULL,
    LINK_ID NUMBER(10,0) NOT NULL,
    APPLY_ORDER NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(40) NOT NULL,
    CONSTRAINT UN_LINK_CONSTRAINTS_REF_1 UNIQUE (LINK_ID, NAME)
);

ALTER TABLE LINK_CONSTRAINTS_REF
    ADD CONSTRAINT LINK_CONSTRAINTS_REF_PK
PRIMARY KEY (CONSTRAINTS_REF_ID);

CREATE INDEX IX_LINK_CONSTRAINTS_REF_1 ON LINK_CONSTRAINTS_REF (LINK_ID);





-----------------------------------------------------------------------------
-- PAGE_SECURITY
-----------------------------------------------------------------------------

CREATE TABLE PAGE_SECURITY
(
    PAGE_SECURITY_ID NUMBER(10,0) NOT NULL,
    PARENT_ID NUMBER(10,0) NOT NULL,
    PATH VARCHAR2(240) NOT NULL,
    NAME VARCHAR2(80) NOT NULL,
    VERSION VARCHAR2(40),
    SUBSITE VARCHAR2(40),
    USER_PRINCIPAL VARCHAR2(40),
    ROLE_PRINCIPAL VARCHAR2(40),
    GROUP_PRINCIPAL VARCHAR2(40),
    MEDIATYPE VARCHAR2(15),
    LOCALE VARCHAR2(20),
    EXT_ATTR_NAME VARCHAR2(15),
    EXT_ATTR_VALUE VARCHAR2(40),
    CONSTRAINT UN_PAGE_SECURITY_1 UNIQUE (PARENT_ID),
    CONSTRAINT UN_PAGE_SECURITY_2 UNIQUE (PATH)
);

ALTER TABLE PAGE_SECURITY
    ADD CONSTRAINT PAGE_SECURITY_PK
PRIMARY KEY (PAGE_SECURITY_ID);






-----------------------------------------------------------------------------
-- PAGE_SEC_CONSTRAINTS_DEF
-----------------------------------------------------------------------------

CREATE TABLE PAGE_SEC_CONSTRAINTS_DEF
(
    CONSTRAINTS_DEF_ID NUMBER(10,0) NOT NULL,
    PAGE_SECURITY_ID NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(40) NOT NULL,
    CONSTRAINT UN_PAGE_SEC_CONSTRAINTS_DEF_1 UNIQUE (PAGE_SECURITY_ID, NAME)
);

ALTER TABLE PAGE_SEC_CONSTRAINTS_DEF
    ADD CONSTRAINT PAGE_SEC_CONSTRAINTS_DEF_PK
PRIMARY KEY (CONSTRAINTS_DEF_ID);

CREATE INDEX IX_PAGE_SEC_CONSTRAINTS_DEF_1 ON PAGE_SEC_CONSTRAINTS_DEF (PAGE_SECURITY_ID);





-----------------------------------------------------------------------------
-- PAGE_SEC_CONSTRAINT_DEF
-----------------------------------------------------------------------------

CREATE TABLE PAGE_SEC_CONSTRAINT_DEF
(
    CONSTRAINT_DEF_ID NUMBER(10,0) NOT NULL,
    CONSTRAINTS_DEF_ID NUMBER(10,0) NOT NULL,
    APPLY_ORDER NUMBER(10,0) NOT NULL,
    USER_PRINCIPALS_ACL VARCHAR2(120),
    ROLE_PRINCIPALS_ACL VARCHAR2(120),
    GROUP_PRINCIPALS_ACL VARCHAR2(120),
    PERMISSIONS_ACL VARCHAR2(120)
);

ALTER TABLE PAGE_SEC_CONSTRAINT_DEF
    ADD CONSTRAINT PAGE_SEC_CONSTRAINT_DEF_PK
PRIMARY KEY (CONSTRAINT_DEF_ID);

CREATE INDEX IX_PAGE_SEC_CONSTRAINT_DEF_1 ON PAGE_SEC_CONSTRAINT_DEF (CONSTRAINTS_DEF_ID);





-----------------------------------------------------------------------------
-- PAGE_SEC_CONSTRAINTS_REF
-----------------------------------------------------------------------------

CREATE TABLE PAGE_SEC_CONSTRAINTS_REF
(
    CONSTRAINTS_REF_ID NUMBER(10,0) NOT NULL,
    PAGE_SECURITY_ID NUMBER(10,0) NOT NULL,
    APPLY_ORDER NUMBER(10,0) NOT NULL,
    NAME VARCHAR2(40) NOT NULL,
    CONSTRAINT UN_PAGE_SEC_CONSTRAINTS_REF_1 UNIQUE (PAGE_SECURITY_ID, NAME)
);

ALTER TABLE PAGE_SEC_CONSTRAINTS_REF
    ADD CONSTRAINT PAGE_SEC_CONSTRAINTS_REF_PK
PRIMARY KEY (CONSTRAINTS_REF_ID);

CREATE INDEX IX_PAGE_SEC_CONSTRAINTS_REF_1 ON PAGE_SEC_CONSTRAINTS_REF (PAGE_SECURITY_ID);





-----------------------------------------------------------------------------
-- PROFILING_RULE
-----------------------------------------------------------------------------

CREATE TABLE PROFILING_RULE
(
    RULE_ID VARCHAR2(80) NOT NULL,
    CLASS_NAME VARCHAR2(100) NOT NULL,
    TITLE VARCHAR2(100)
);

ALTER TABLE PROFILING_RULE
    ADD CONSTRAINT PROFILING_RULE_PK
PRIMARY KEY (RULE_ID);






-----------------------------------------------------------------------------
-- RULE_CRITERION
-----------------------------------------------------------------------------

CREATE TABLE RULE_CRITERION
(
    CRITERION_ID VARCHAR2(80) NOT NULL,
    RULE_ID VARCHAR2(80) NOT NULL,
    FALLBACK_ORDER NUMBER(10,0) NOT NULL,
    REQUEST_TYPE VARCHAR2(40) NOT NULL,
    NAME VARCHAR2(80) NOT NULL,
    COLUMN_VALUE VARCHAR2(128),
    FALLBACK_TYPE NUMBER(10,0) default 1
);

ALTER TABLE RULE_CRITERION
    ADD CONSTRAINT RULE_CRITERION_PK
PRIMARY KEY (CRITERION_ID);

CREATE INDEX IX_RULE_CRITERION_1 ON RULE_CRITERION (RULE_ID, FALLBACK_ORDER);





-----------------------------------------------------------------------------
-- PRINCIPAL_RULE_ASSOC
-----------------------------------------------------------------------------

CREATE TABLE PRINCIPAL_RULE_ASSOC
(
    PRINCIPAL_NAME VARCHAR2(80) NOT NULL,
    LOCATOR_NAME VARCHAR2(80) NOT NULL,
    RULE_ID VARCHAR2(80) NOT NULL
);

ALTER TABLE PRINCIPAL_RULE_ASSOC
    ADD CONSTRAINT PRINCIPAL_RULE_ASSOC_PK
PRIMARY KEY (PRINCIPAL_NAME,LOCATOR_NAME);






-----------------------------------------------------------------------------
-- PROFILE_PAGE_ASSOC
-----------------------------------------------------------------------------

CREATE TABLE PROFILE_PAGE_ASSOC
(
    LOCATOR_HASH VARCHAR2(40) NOT NULL,
    PAGE_ID VARCHAR2(80) NOT NULL,
    CONSTRAINT UN_PROFILE_PAGE_1 UNIQUE (LOCATOR_HASH, PAGE_ID)
);







-----------------------------------------------------------------------------
-- CLUBS
-----------------------------------------------------------------------------

CREATE TABLE CLUBS
(
    NAME VARCHAR2(80) NOT NULL,
    COUNTRY VARCHAR2(40) NOT NULL,
    CITY VARCHAR2(40) NOT NULL,
    STADIUM VARCHAR2(80) NOT NULL,
    CAPACITY NUMBER(10,0),
    FOUNDED NUMBER(10,0),
    PITCH VARCHAR2(40),
    NICKNAME VARCHAR2(40)
);

ALTER TABLE CLUBS
    ADD CONSTRAINT CLUBS_PK
PRIMARY KEY (NAME);





ALTER TABLE FOLDER
    ADD CONSTRAINT FK_FOLDER_1 FOREIGN KEY (PARENT_ID)
    REFERENCES FOLDER (FOLDER_ID)
ON DELETE CASCADE
;



ALTER TABLE FOLDER_METADATA
    ADD CONSTRAINT FK_FOLDER_METADATA_1 FOREIGN KEY (FOLDER_ID)
    REFERENCES FOLDER (FOLDER_ID)
ON DELETE CASCADE
;



ALTER TABLE FOLDER_CONSTRAINT
    ADD CONSTRAINT FK_FOLDER_CONSTRAINT_1 FOREIGN KEY (FOLDER_ID)
    REFERENCES FOLDER (FOLDER_ID)
ON DELETE CASCADE
;



ALTER TABLE FOLDER_CONSTRAINTS_REF
    ADD CONSTRAINT FK_FOLDER_CONSTRAINTS_REF_1 FOREIGN KEY (FOLDER_ID)
    REFERENCES FOLDER (FOLDER_ID)
ON DELETE CASCADE
;



ALTER TABLE FOLDER_ORDER
    ADD CONSTRAINT FK_FOLDER_ORDER_1 FOREIGN KEY (FOLDER_ID)
    REFERENCES FOLDER (FOLDER_ID)
ON DELETE CASCADE
;



ALTER TABLE FOLDER_MENU
    ADD CONSTRAINT FK_FOLDER_MENU_1 FOREIGN KEY (PARENT_ID)
    REFERENCES FOLDER_MENU (MENU_ID)
ON DELETE CASCADE
;

ALTER TABLE FOLDER_MENU
    ADD CONSTRAINT FK_FOLDER_MENU_2 FOREIGN KEY (FOLDER_ID)
    REFERENCES FOLDER (FOLDER_ID)
ON DELETE CASCADE
;



ALTER TABLE FOLDER_MENU_METADATA
    ADD CONSTRAINT FK_FOLDER_MENU_METADATA_1 FOREIGN KEY (MENU_ID)
    REFERENCES FOLDER_MENU (MENU_ID)
ON DELETE CASCADE
;



ALTER TABLE PAGE
    ADD CONSTRAINT FK_PAGE_1 FOREIGN KEY (PARENT_ID)
    REFERENCES FOLDER (FOLDER_ID)
ON DELETE CASCADE
;



ALTER TABLE PAGE_METADATA
    ADD CONSTRAINT FK_PAGE_METADATA_1 FOREIGN KEY (PAGE_ID)
    REFERENCES PAGE (PAGE_ID)
ON DELETE CASCADE
;



ALTER TABLE PAGE_CONSTRAINT
    ADD CONSTRAINT FK_PAGE_CONSTRAINT_1 FOREIGN KEY (PAGE_ID)
    REFERENCES PAGE (PAGE_ID)
ON DELETE CASCADE
;



ALTER TABLE PAGE_CONSTRAINTS_REF
    ADD CONSTRAINT FK_PAGE_CONSTRAINTS_REF_1 FOREIGN KEY (PAGE_ID)
    REFERENCES PAGE (PAGE_ID)
ON DELETE CASCADE
;



ALTER TABLE PAGE_MENU
    ADD CONSTRAINT FK_PAGE_MENU_1 FOREIGN KEY (PARENT_ID)
    REFERENCES PAGE_MENU (MENU_ID)
ON DELETE CASCADE
;

ALTER TABLE PAGE_MENU
    ADD CONSTRAINT PM_M_FK_PAGE_ID_PAGE FOREIGN KEY (PAGE_ID)
    REFERENCES PAGE (PAGE_ID)
ON DELETE CASCADE
;



ALTER TABLE PAGE_MENU_METADATA
    ADD CONSTRAINT FK_PAGE_MENU_METADATA_1 FOREIGN KEY (MENU_ID)
    REFERENCES PAGE_MENU (MENU_ID)
ON DELETE CASCADE
;



ALTER TABLE FRAGMENT
    ADD CONSTRAINT FK_FRAGMENT_1 FOREIGN KEY (PARENT_ID)
    REFERENCES FRAGMENT (FRAGMENT_ID)
ON DELETE CASCADE
;

ALTER TABLE FRAGMENT
    ADD CONSTRAINT FK_FRAGMENT_2 FOREIGN KEY (PAGE_ID)
    REFERENCES PAGE (PAGE_ID)
ON DELETE CASCADE
;



ALTER TABLE FRAGMENT_CONSTRAINT
    ADD CONSTRAINT FK_FRAGMENT_CONSTRAINT_1 FOREIGN KEY (FRAGMENT_ID)
    REFERENCES FRAGMENT (FRAGMENT_ID)
ON DELETE CASCADE
;



ALTER TABLE FRAGMENT_CONSTRAINTS_REF
    ADD CONSTRAINT FK_FRAGMENT_CONSTRAINTS_REF_1 FOREIGN KEY (FRAGMENT_ID)
    REFERENCES FRAGMENT (FRAGMENT_ID)
ON DELETE CASCADE
;



ALTER TABLE FRAGMENT_PREF
    ADD CONSTRAINT FK_FRAGMENT_PREF_1 FOREIGN KEY (FRAGMENT_ID)
    REFERENCES FRAGMENT (FRAGMENT_ID)
ON DELETE CASCADE
;



ALTER TABLE FRAGMENT_PREF_VALUE
    ADD CONSTRAINT FK_FRAGMENT_PREF_VALUE_1 FOREIGN KEY (PREF_ID)
    REFERENCES FRAGMENT_PREF (PREF_ID)
ON DELETE CASCADE
;



ALTER TABLE LINK
    ADD CONSTRAINT FK_LINK_1 FOREIGN KEY (PARENT_ID)
    REFERENCES FOLDER (FOLDER_ID)
ON DELETE CASCADE
;



ALTER TABLE LINK_METADATA
    ADD CONSTRAINT FK_LINK_METADATA_1 FOREIGN KEY (LINK_ID)
    REFERENCES LINK (LINK_ID)
ON DELETE CASCADE
;



ALTER TABLE LINK_CONSTRAINT
    ADD CONSTRAINT FK_LINK_CONSTRAINT_1 FOREIGN KEY (LINK_ID)
    REFERENCES LINK (LINK_ID)
ON DELETE CASCADE
;



ALTER TABLE LINK_CONSTRAINTS_REF
    ADD CONSTRAINT FK_LINK_CONSTRAINTS_REF_1 FOREIGN KEY (LINK_ID)
    REFERENCES LINK (LINK_ID)
ON DELETE CASCADE
;



ALTER TABLE PAGE_SECURITY
    ADD CONSTRAINT FK_PAGE_SECURITY_1 FOREIGN KEY (PARENT_ID)
    REFERENCES FOLDER (FOLDER_ID)
ON DELETE CASCADE
;



ALTER TABLE PAGE_SEC_CONSTRAINTS_DEF
    ADD CONSTRAINT FK_PAGE_SEC_CONSTRAINTS_DEF_1 FOREIGN KEY (PAGE_SECURITY_ID)
    REFERENCES PAGE_SECURITY (PAGE_SECURITY_ID)
ON DELETE CASCADE
;



ALTER TABLE PAGE_SEC_CONSTRAINT_DEF
    ADD CONSTRAINT FK_PAGE_SEC_CONSTRAINT_DEF_1 FOREIGN KEY (CONSTRAINTS_DEF_ID)
    REFERENCES PAGE_SEC_CONSTRAINTS_DEF (CONSTRAINTS_DEF_ID)
ON DELETE CASCADE
;



ALTER TABLE PAGE_SEC_CONSTRAINTS_REF
    ADD CONSTRAINT FK_PAGE_SEC_CONSTRAINTS_REF_1 FOREIGN KEY (PAGE_SECURITY_ID)
    REFERENCES PAGE_SECURITY (PAGE_SECURITY_ID)
ON DELETE CASCADE
;





ALTER TABLE RULE_CRITERION
    ADD CONSTRAINT FK_RULE_CRITERION_1 FOREIGN KEY (RULE_ID)
    REFERENCES PROFILING_RULE (RULE_ID)
ON DELETE CASCADE
;









