Commit efca5be0 authored by Leon Do Castelo's avatar Leon Do Castelo
Browse files

debug des requêtes de création avec sqlite

parent 99542619
......@@ -10,13 +10,21 @@ Database::Database(std::string path): db(QSqlDatabase::addDatabase("QSQLITE")) {
}
db.exec("CREATE TABLE IF NOT EXISTS automates (nom VARCHAR(30) PRIMARY KEY, defaut INTEGER NOT NULL)");
db.exec("CREATE TABLE IF NOT EXISTS regles_transition (id VARCHAR(30) REFERENCES automate(nom) NOT NULL, min1 INTEGER, min2 INTEGER, min3 INTEGER, min4 INTEGER, min5 INTEGER, min6 INTEGER, min7 INTEGER, min8 INTEGER, max1 INTEGER, max2 INTEGER, max3 INTEGER, max4 INTEGER, max5 INTEGER, max6 INTEGER, max7 INTEGER, max8 INTEGER, courant INTEGER, destination INTEGER NOT NULL)");
db.exec("CREATE TABLE IF NOT EXISTS regles_voisinage (id VARCHAR(30) PRIMARY KEY REFERENCES automates(nom), type INTEGER NOT NULL, rayon INTEGER)");
db.exec("CREATE TABLE IF NOT EXISTS coord_voisinage (id VARCHAR(30) REFERENCES automates(nom) NOT NULL, x INTEGER NOT NULL, y INTEGER NOT NULL)");
db.exec("CREATE TABLE IF NOT EXISTS reseaux (id INTEGER PRIMARY KEY, nom VARCHAR(30) NOT NULL, h INTEGER NOT NULL, l INTEGER NOT NULL, automate VARCHAR(30) REFERENCES automates(nom) NOT NULL)");
db.exec("CREATE TABLE IF NOT EXISTS EnsembleEtats (id INTEGER PRIMARY KEY, automate VARCHAR(30) REFERENCES automates(nom) NOT NULL, UNIQUE(automate));");
db.exec("CREATE TABLE IF NOT EXISTS Etats (ensemble INTEGER REFERENCES EnsembleEtats(id) NOT NULL, indice INTEGER NOT NULL, label VARCHAR NOT NULL, r INTEGER NOT NULL, g INTEGER NOT NULL, b INTEGER NOT NULL, CHECK(indice>=0), CHECK(r>=0), CHECK(r<=255), CHECK(g>=0), CHECK(g<=255), CHECK(b>=0), CHECK(b<=255), PRIMARY KEY (ensemble, indice))");
db.exec("CREATE TABLE IF NOT EXISTS Cellules (reseau INTEGER REFERENCES reseau(id) NOT NULL, ensemble INTEGER REFERENCES EnsembleEtats(id) NOT NULL, etat INTEGER REFERENCES Etats(indice) NOT NULL, x INTEGER NOT NULL, y INTEGER NOT NULL);");
db.exec("CREATE TABLE IF NOT EXISTS regles_transition (id VARCHAR(30) NOT NULL, min1 INTEGER, min2 INTEGER, min3 INTEGER, min4 INTEGER, min5 INTEGER, min6 INTEGER, min7 INTEGER, min8 INTEGER, max1 INTEGER, max2 INTEGER, max3 INTEGER, max4 INTEGER, max5 INTEGER, max6 INTEGER, max7 INTEGER, max8 INTEGER, courant INTEGER, destination INTEGER NOT NULL, FOREIGN KEY('id') REFERENCES 'automates'('nom'))");
db.exec("CREATE TABLE IF NOT EXISTS regles_voisinage (id VARCHAR(30) PRIMARY KEY, type INTEGER NOT NULL, rayon INTEGER, FOREIGN KEY('id') REFERENCES 'automates'('nom'))");
db.exec("CREATE TABLE IF NOT EXISTS coord_voisinage (id VARCHAR(30) NOT NULL, x INTEGER NOT NULL, y INTEGER NOT NULL,FOREIGN KEY('id') REFERENCES 'automates'('nom'))");
db.exec("CREATE TABLE IF NOT EXISTS reseaux (id INTEGER PRIMARY KEY, nom VARCHAR(30) NOT NULL, h INTEGER NOT NULL, l INTEGER NOT NULL, automate VARCHAR(30) NOT NULL, FOREIGN KEY('automate') REFERENCES 'automates'('nom'))");
db.exec("CREATE TABLE IF NOT EXISTS EnsembleEtats (id INTEGER PRIMARY KEY, automate VARCHAR(30) NOT NULL, UNIQUE(automate), FOREIGN KEY('automate') REFERENCES 'automates'('nom'))");
db.exec("CREATE TABLE IF NOT EXISTS Etats (ensemble INTEGER NOT NULL, indice INTEGER NOT NULL, label VARCHAR NOT NULL, r INTEGER NOT NULL, g INTEGER NOT NULL, b INTEGER NOT NULL, CHECK(indice>=0), CHECK(r>=0), CHECK(r<=255), CHECK(g>=0), CHECK(g<=255), CHECK(b>=0), CHECK(b<=255), PRIMARY KEY (ensemble, indice), FOREIGN KEY(ensemble') REFERENCES 'EnsembleEtats'('id'))");
db.exec("CREATE TABLE IF NOT EXISTS Cellules (reseau INTEGER NOT NULL, ensemble INTEGER NOT NULL, etat INTEGER NOT NULL, x INTEGER NOT NULL, y INTEGER NOT NULL, FOREIGN KEY('reseau') REFERENCES 'reseaux'('id'))");
}
std::vector<QString> Database::getAutomates() const {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment