dubbio sql Clicca QUI per vedere il messaggio nel forum | 
 
| Mr.O | 
 
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;
  
  | 
 
 
 
| Ste.dv | 
 
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. | 
 
 
 
| Mr.O | 
 
questo e' lo schema  
 
code: 
Corso(CodC, Nomenn, Docentenn) 
Lezione(CodC fk->Corso.CodC, CodP fk->Periodo.CodP,Aulann,Edificionn) 
Periodo(CodP, Giornonn, OraInn)
  
  | 
 
 
 
| Ste.dv | 
 
Sì, confermo. 
Il natural join realizza esattamente la stessa operazione. | 
 
 
 
 | 
 
 
 | 
 
 
 |