lunedì 1 dicembre 2008

lunedi 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 values studente(1, 'Silvano', 33, 'via del falco');
insert into values studente(2, 'andrea', 33, 'via francia');
insert into values studente(3, 'luca', 33, 'via garibaldi');

insert into values cd(1,'vasco','a', 15);
insert into values cd(2,'tizio','b', 13);
insert into values cd(3,'caio','b', 12);

insert into values compra(1, 2, 3, 26/9/2008);
insert into values compra(2, 3, 1, 25/10/2008);
insert into values compra(2, 3, 1, 27/11/2008);

.mode coluan
.headers
select * from studente;
select * from cd;
select * from guida;

select studente.nome, cd.titolo, cd.prezzo;
from studente, cd, compra
where studente.codice=compra.codiceStudente and cd.codice=compra.codiceCd and compra.codiceStudente=2;

Nessun commento: