martedì 16 dicembre 2008



sqlite3 registroVoti.db
definiamo le create table per ogni tabella relazionale del nostro database
CREATE TABLE DOCENTE (idDocente integer primary key, nome text, classeConcorso text, blog text, email text, foto blob);
CREATE TABLE STUDENTE(idStudente integer primary key, nome text, classe text, email text, foto blob);
CREATE TABLE MATERIA(idMateria integer primary key, nome text, descrizione text);
CREATE TABLE MODULO(idMateria integer references MATERIA, idModulo integer, nome text, descrizione text, obiettivo text, primary key(idMateria, idModulo));
CREATE TABLE VOTO(idVoto integer primary key autoincrement, tipo text, voto integer, data text, argomento text, idStudente integer references STUDENTE, idMateria integer references MATERIA, idModulo integer references MODULO, idDocente integer references DOCENTE);
CREATE TABLE PROGRAMMAZIONE(idProgramma integer primary key, idDocente integer references DOCENTE, idMateria integer references MATERIA, idModulo integer references MODULO, mmaaInizio text, mmaaFine text);

lunedì 1 dicembre 2008



/TABELLE/
STUDENTE (codice, nome, indirizzo, età);
COMPRA (numProg, *codStud, *codicecd, data);
CD (codicCd, autore, titolo, prezzo);

/Codice MYSQL/
create table studente(codice integer primary key, nome text, eta intger, indirizzo text);
create table cd(codice integer primary key, autore text, titolo text, prezzo intger);
create table compra(numProg primary key, codiceCd integer foreing key, codiceStudente foreing key, data text);

insert into studente values(1, 'Daniele', 'via fontanelle', 18);
insert into studente values(2, 'Matteo', 'via tuderte', 18);
insert into studente values(3, 'Andrea', 'via roberto rovatti' 19);

insert into compra values(1, 2, 3, 23/12/2008);
insert into compra values(2, 3, 1, 31/12/2008);
insert into compra values(3, 3, 1, 7/12/2008);

insert into cd values(1,'coldplay','viva la vida', 30);
insert into cd values(2,'sum41','underclass hero', 25);
insert into cd values(3,'muse','black holes and revelations', 40);

.mode coluan.headersselect * from studente;select * from cd;
select * from compra;
select studente.nome, cd.titolo, cd.prezzo;
from studente, cd, compra;
where studente.codice = compra.codiceStudente and cd.codice = compra.codiceCd and compra.codiceStudente = 3;