.dsy:it.
Show 150 posts per page

.dsy:it. (http://www.dsy.it/forum/)
- Basi di dati ~ comunicazione digitale (http://www.dsy.it/forum/forumdisplay.php?forumid=108)
-- dubbio sql (http://www.dsy.it/forum/showthread.php?threadid=38689)


Posted by Mr.O on 27-06-2009 10:28:

dubbio sql

qlc sa dirmi se questa interrogazione :

code:
select Docente, count(*) from Corso, Lezione, Periodo where Corso.CodC=Lezione.CodC and Lezione.CodP=Corso.CodP and (Giorno=’Lunedì’ or Giorno=’Martedì’) and Aula=’Alfa’ group by Docente having count (distinct Corso.CodC)=2;


la posso scrivere anche cosi' :

code:
select Docente, count(*) from Corso natural join Lezione natural join Periodo where (Giorno=’Lunedì’ or Giorno=’Martedì’) and Aula=’Alfa’ group by Docente having count (distinct Corso.CodC)=2;


Posted by Ste.dv on 27-06-2009 11:22:

Se ricordo bene gli schemi delle relazioni Corso, Lezione e Periodo sì: è lo stesso.
In generale devi solo assicurarti che non vi siano attributi omonimi oltre ai riferimenti (in questo caso CodC e CodP) che legano le relazioni.


Posted by Mr.O on 27-06-2009 11:31:

questo e' lo schema

code:
Corso(CodC, Nomenn, Docentenn) Lezione(CodC fk->Corso.CodC, CodP fk->Periodo.CodP,Aulann,Edificionn) Periodo(CodP, Giornonn, OraInn)


Posted by Ste.dv on 27-06-2009 11:57:

Sì, confermo.
Il natural join realizza esattamente la stessa operazione.


All times are GMT. The time now is 03:13.
Show all 4 posts from this thread on one page

Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.