wiki:db/Metadata/Strawman01
Last modified 6 years ago Last modified on 02/01/2013 01:41:14 PM

Metadata - strawman idea

-- define all supported types
-- hardcode type ids and never change, append at the end
-- if new types needed
CREATE TABLE mtd_Types (
     typeId TINYINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
     typeName VARCHAR(32)
);
INSERT INTO mtd_Tables(typeName)
     VALUES("int", "float", "double", "string");


-- the core metadata class defines key:value relationship
-- and pointer to parent
CREATE TABLE mtd_Metadata (
    metadataId  BIGINT AUTO_INCREMENT PRIMARY KEY,
    keyName     VARCHAR(32) NOT NULL,
    dataType    TINYINT NOT NULL, -- ?????
    hasChildren BOOL,             -- ?????
    parentId    BIGINT, -- ptr to other mtd_metadata or NULL
)


-- one table for each supported type,
-- add new table for each new type
CREATE TABLE mtd_Int (
    metadataId BIGINT,
    value INT,
    INDEX(metadataId)
);
CREATE TABLE mtd_Float (
    metadataId BIGINT,
    value FLOAT,
    INDEX(metadataId)
);
CREATE TABLE mtd_Double (
    metadataId BIGINT,
    value DOUBLE,
    INDEX(metadataId)
);
CREATE TABLE mtd_String (
    metadataId BIGINT,
    value VARCHAR(1024),
    INDEX(metadataId)
);