CREATE TABLE `bilde` ( `idbilde` int(11) NOT NULL, `hvor` varchar(100) DEFAULT NULL, `tekst` varchar(256) DEFAULT NULL, `alt` varchar(100) DEFAULT NULL, PRIMARY KEY (`idbilde`) ); CREATE TABLE `valg` ( `idvalg` int(11) NOT NULL, `startforslag` datetime DEFAULT NULL, `sluttforslag` datetime DEFAULT NULL, `startvalg` datetime DEFAULT NULL, `sluttvalg` datetime DEFAULT NULL, `kontrollert` datetime DEFAULT NULL, PRIMARY KEY (`idvalg`) ); CREATE TABLE `kandidat` ( `bruker` varchar(100) NOT NULL, `fakultet` varchar(45) DEFAULT NULL, `institutt` varchar(45) DEFAULT NULL, `informasjon` longtext DEFAULT NULL, `stemmer` int(11) DEFAULT NULL, `bilde` int(11) DEFAULT NULL, PRIMARY KEY (`bruker`), KEY `bilde_idbilde_idx` (`bilde`), CONSTRAINT `bilde_idbilde` FOREIGN KEY (`bilde`) REFERENCES `bilde` (`idbilde`) ); CREATE TABLE `brukertype` ( `idbrukertype` int(11) NOT NULL, `type` varchar(45) DEFAULT NULL, PRIMARY KEY (`idbrukertype`) ); CREATE TABLE `bruker` ( `epost` varchar(100) NOT NULL, `passord` varchar(40) DEFAULT NULL, `enavn` varchar(45) DEFAULT NULL, `fnavn` varchar(45) DEFAULT NULL, `brukertype` int(11) NOT NULL, `stemme` varchar(100) DEFAULT NULL, `fdato` date DEFAULT NULL, `mann` char(1) DEFAULT NULL, `antallforsok` int(11) DEFAULT NULL, `sisteforsok` datetime DEFAULT NULL, PRIMARY KEY (`epost`), KEY `bruker_type_idx` (`brukertype`), KEY `kandidat_stemme_idx` (`stemme`), CONSTRAINT `bruker_type` FOREIGN KEY (`brukertype`) REFERENCES `brukertype` (`idbrukertype`), CONSTRAINT `kandidat_stemme` FOREIGN KEY (`stemme`) REFERENCES `kandidat` (`bruker`) ); insert into brukertype values (2, "ordinærbruker"); insert into bruker (epost, brukertype, passord) values ("test", 2, "4914596cec406ed6b97d2123b9454c2717b8e3ef");