[supersaibal]Originariamente inviato da Fabio Heller
I tirocinii hanno dati propri (es, nome del tipo di tirocinio etc.etc.)?

Una struttura di questo tipo non va bene?

tesi
----------
id_tesi
autore
altro...


tirocini
----------
id_tirocinio
id_tesi
altro...


Le tesi che non hanno tirocinio sono assenti dalla seconda tabella e le ricavi da un left join tra la tabella tesi e quella tirocini WHERE id_tirocinio is null

Io ho usato degli id come chiavi primarie, ma se ci sono delle chiavi naturali meglio [/supersaibal]
ma id_tesi in tirocini cmq non puo essere ua FK, altrimenti il problema resta xke come detto sopra non tutti i tirocini hanno una tesi assegnata (ed non tutte le tesi anno un tirocinio assegnato)

Io come detto sopra o risolto (anche se non mi piace tanto come soluzione) eliminando la FK ed creando una procedura:

codice:
begin
  /* Procedure Text */
  if (idtesi is null) then
    begin
        idts= null;
    end
    else
        begin
          if (not exists(select  t.idtesi from tesi t
                            where t.idtesi = :idtesi and t.tipo='P' and t.stato='C')) then
                                exception FK_ERROR;
    
                      select  t.tipo, t.stato from tesi t
                            where t.idtesi = :idtesi into :t, :s;
            
            if (t='P' and s='C') then
                idts = idtesi;
             else
                exception NO_CONTINUA;
        end

  suspend;
end
da utilizzare quando si fa un insert cosi da controllare il FK a mano