
select distinct pezzo from
  automezzi join cambiostati
    on automezzi.matricola = cambiostati.matricola
  join fogliodiriparazione
    on cambiostati.id_cambio_stato = fogliodiriparazione.id_cambio_stato
  where marca = 'FIAT' and pezzo is not null;

select distinct pezzo from
  automezzi as a join cambiostati as c
    on a.matricola = c.matricola
  join fogliodiriparazione as f
    on c.id_cambio_stato = f.id_cambio_stato
  where marca = 'FIAT' and pezzo is not null;

select distinct pezzo,a.matricola,cognome,nome from
  automezzi as a join cambiostati as c
    on a.matricola = c.matricola
  join fogliodiriparazione as f
    on c.id_cambio_stato = f.id_cambio_stato
  join meccanici as m
    on f.meccanico = m.matricola
  where pezzo is not null and year (f.data) = 2003;

select distinct pezzo,a.matricola,cognome,nome from
  automezzi as a natural join cambiostati as c
  natural join fogliodiriparazione as f
  join meccanici as m
    on f.meccanico = m.matricola
  where pezzo is not null and year (f.data) = 2003;

select automezzi.matricola, intervento, pezzo, data from
  automezzi natural join cambiostati
  natural join fogliodiriparazione
  order by automezzi.matricola, data;

select intervento, pezzo, data from
  automezzi natural join cambiostati
  natural join fogliodiriparazione
  where automezzi.matricola = 1
  order by data;

