The Datalog rule below for none_of_manufacturer was intended to list those aircraft manufacturers for which the airline has no aircraft in its fleet. The fragment of Datalog below, however, does not do what it was intended to do.
none_of_manufacturer(Man) :- aircraft_type(Model, Man, _), ¬ model_in_fleet(Model). model_in_fleet(Model) :- aircraft(_, Model, _).
what can i do to the above query to fix it?
I thought of one suggestion:
none_of_manufacturer(Man) :- aircraft_type(Model, Man, _), ¬ model_in_fleet(Model, Man). model_in_fleet(Model, Man) :- aircraft(_, Model, _), aircraft_type(_ ,Man, _).
What do you guys think? I have attached the tables below
aircraft --------------------------- | reg | model | miles | |---------------------------| |G-CWQS |737-400C | 2945321 | |G-FDWC |737-400 | 506834 | |G-FXDC |737-400 | 34760 | |G-KLSD |737-400 | 590 | |G-UGHJ |380 | 4544 | -----------------------------
aircraft_type ------------------------------------- |model | manufacturer| no_engines | -------------------------------------| |727 | Boeing | 3 | |737-200 | Boeing | 2 | |737-400 | Boeing | 2 | |737-400C| Boeing | 2 | |737-500 | Boeing | 2 | |380 | Airbus | 4 | |747 | Boeing | 4 | |MD11 | MD | 3 | --------------------------------------
Update
I have discovered a technique which could solve the problem. Considering the original query returned the manufacture of models not in the aircraft table which in this case would be Boing for the following missing planes (727,737-200,737,500) and MD for (MD11). Our ultimate result is MD as we do not have a MD plane so
Existing_manufacturer(Man):-aircraft_type(Model,Man,-),aircraft(_,Model,). returns the manufacturer of existing planes Boing and Airbus. Now if we were to use the previous query in the original none_of_manufacturer(Man) :- aircraft_type(_ ,Man, _), ¬ Existing_manufacturer(Man). Will calculate the difference and return only MD.