CREATE TABLE IF NOT EXISTS projekt (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
ime VARCHAR(45) NULL,
PRIMARY KEY(id)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS solucije (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
ime VARCHAR(45) NULL,
PRIMARY KEY(id)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS tmp (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
prid INTEGER UNSIGNED NOT NULL,
stupci VARCHAR(255) NULL,
redIme VARCHAR(45) NULL,
red VARCHAR(255) NULL,
PRIMARY KEY(id),
INDEX tmp_FKIndex1(prid),
FOREIGN KEY(prid)
REFERENCES projekt(id)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS atribut (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
prid INTEGER UNSIGNED NOT NULL,
ime VARCHAR(45) NULL,
Jedinica INTEGER UNSIGNED NULL,
VM TINYINT UNSIGNED NULL,
PRIMARY KEY(id),
INDEX atribut_FKIndex1(prid),
FOREIGN KEY(prid)
REFERENCES projekt(id)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS matrica (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
atribid1 INTEGER UNSIGNED NOT NULL,
atribid2 INTEGER UNSIGNED NOT NULL,
iznos FLOAT NULL,
PM TINYINT UNSIGNED NULL,
PRIMARY KEY(id),
INDEX matrica_FKIndex1(atribid1),
INDEX matrica_FKIndex2(atribid2),
FOREIGN KEY(atribid1)
REFERENCES atribut(id)
ON DELETE CASCADE
ON UPDATE NO ACTION,
FOREIGN KEY(atribid2)
REFERENCES atribut(id)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS sol_tab (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
solid INTEGER UNSIGNED NULL,
atribid INTEGER UNSIGNED NULL,
iznos INTEGER UNSIGNED NULL,
PRIMARY KEY(id),
INDEX sol_tab_FKIndex1(solid),
INDEX sol_tab_FKIndex2(atribid),
FOREIGN KEY(solid)
REFERENCES solucije(id)
ON DELETE CASCADE
ON UPDATE NO ACTION,
FOREIGN KEY(atribid)
REFERENCES atribut(id)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;
|