% prov(Country) refs country(code) on delete cascade
del_province(PN,C,PPop,PA,PCap,PCapProv) :- del_country(N,C,Cap,CapP,A,P),
    province(PN,C,PPop,PA,PCap,PCapProv).
% city(Country) refs country(code) on delete set null
upd_city(CN,C,CP,CPop,Lat,Long,El,CN,null,CP,CPop,Lat,Long,El) :-
    del_country(N,C,Cap,CapP,A,P), city(CN,C,CP,CPop,Lat,Long,El).
% city(Country,Province) refs province(name,country) on delete cascade
del_city(CN,C,PN,CPop,Lat,Long,El) :-  del_province(PN,C,PPop,PA,PCap,PCapProv),
    city(CN,C,PN,CPop,Lat,Long,El).
inconsistent :-  del_city(CN,C,CP,CPop,Lat,Long,El),
                 upd_city(CN,C,CP,CPop,Lat,Long,El,CN2,C2,CP2,CPop2,Lat2,Long2,El2).
country("Germany","D","Berlin","Berlin",356910,83536115).
province("Berlin","D",3472009,889,"Berlin","Berlin").
city("Berlin","D","Berlin",3472009,13,52,null).
del_country("Germany","D","Berlin","Berlin",356910,83536115).
% ?- inconsistent.
