CREATE TABLE FileDataType
(
    id BIGINT UNSIGNED DEFAULT NULL,
    nodeId BIGINT UNSIGNED DEFAULT NULL,
    fieldName VARCHAR(35) DEFAULT NULL,
    lang_id CHAR(3) DEFAULT NULL,
    sort_order INT UNSIGNED DEFAULT 0,
    mimeType BIGINT UNSIGNED DEFAULT NULL,
    hash CHAR(32) DEFAULT NULL,
    originalName VARCHAR(50) DEFAULT NULL,
    file VARCHAR(255) DEFAULT NULL,
    fileName VARCHAR(255) DEFAULT NULL,
    length DECIMAL(5,2) DEFAULT NULL,
    PRIMARY KEY ( id ) AUTO_INCREMENT,
    KEY fileName ( fileName,id ),
    UNIQUE KEY ( nodeId,fieldName,lang_id,sort_order )
    /* ,                      This table is huge and the alter table will take too long                      FOREIGN KEY ( nodeId ) REFERENCES nodes ( id ) ON DELETE CASCADE ON UPDATE CASCADE */

) ENGINE=INNODB CHARSET=UTF8 COMMENT="File Storage";
