/*For Simple, we obtain these queries:*/

/*CREATED*/

SELECT mID, cID, tID, itemID, uPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query0 WHERE stamp<NOW();

/*DETACHED*/

SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query2.stamp,Query10.stamp1) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query2 NATURAL JOIN (SELECT mID, cID, tID, qty, addr, pPrice ,stamp AS stamp1 FROM (SELECT mID, cID, tID, qty, addr, pPrice, GREATEST(Query3.stamp,Query12.stamp2) AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query3 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp2 FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query4.stamp,Query14.stamp3) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query4 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp3 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query5) AS Query14 WHERE '1000-01-01 00:00:00'<=Query4.stamp AND Query4.stamp<Query14.stamp3+Interval 4 day) AS Query6) AS Query12) AS Query7) AS Query10) AS Query8 WHERE stamp<NOW();

/*EXPIRED*/

SELECT mID, cID, tID, itemID, uPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, LEAST(COALESCE(Query18.stamp,Query25.stamp4),COALESCE(Query25.stamp4,Query18.stamp)) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, GREATEST(Query16.stamp,Query36.stamp5) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query16 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp5 FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'1000-01-01 00:00:00') AS Query29) AS Query36) AS Query30 UNION SELECT mID, cID, tID, itemID, uPrice, GREATEST(stamp,CAST('9999-12-31 23:59:59' AS DATETIME)) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query33 WHERE (mID, cID, tID) NOT IN (SELECT mID, cID, tID FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'9999-12-31 23:59:59') AS Query32)) AS Query33) AS Query18 NATURAL LEFT OUTER JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp4 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, pPrice, GREATEST(Query19.stamp,Query47.stamp7) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query19 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp7 FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'1000-01-01 00:00:00') AS Query38) AS Query47) AS Query39 UNION SELECT mID, cID, tID, itemID, uPrice, GREATEST(Query42.stamp,Query44.stamp6) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query42 WHERE (mID, cID, tID) NOT IN (SELECT mID, cID, tID FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query20.stamp,Query49.stamp8) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query20 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp8 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query21) AS Query49 WHERE '1000-01-01 00:00:00'<=Query20.stamp AND Query20.stamp<Query49.stamp8+Interval 4 day) AS Query41)) AS Query42 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp6 FROM (SELECT mID, cID, tID, itemID, uPrice ,stamp+Interval 4 day AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) ASQuery21) AS Query43) AS Query44) AS Query22) AS Query25 UNION SELECT mID, cID, tID, itemID, uPrice, LEAST(COALESCE(Query18.stamp,Query25.stamp4),COALESCE(Query25.stamp4,Query18.stamp)) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, GREATEST(Query16.stamp,Query58.stamp9) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query16 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp9 FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'1000-01-01 00:00:00') AS Query51) AS Query58) AS Query52 UNION SELECT mID, cID, tID, itemID, uPrice, GREATEST(stamp,CAST('9999-12-31 23:59:59' AS DATETIME)) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query55 WHERE (mID, cID, tID) NOT IN (SELECT mID, cID, tID FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'9999-12-31 23:59:59') AS Query54)) AS Query55) AS Query18 NATURAL RIGHT OUTER JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp4 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, pPrice, GREATEST(Query19.stamp,Query69.stamp11) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query19 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp11 FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'1000-01-01 00:00:00') AS Query60) AS Query69) AS Query61 UNION SELECT mID, cID, tID, itemID, uPrice, GREATEST(Query64.stamp,Query66.stamp10) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query64 WHERE (mID, cID, tID) NOT IN (SELECT mID, cID, tID FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query20.stamp,Query71.stamp12) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query20 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp12 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query21) AS Query71 WHERE '1000-01-01 00:00:00'<=Query20.stamp AND Query20.stamp<Query71.stamp12+Interval 4 day) AS Query63)) AS Query64 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp10 FROM (SELECT mID, cID, tID, itemID, uPrice ,stamp+Interval 4 day AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) ASQuery21) AS Query65) AS Query66) AS Query22) AS Query25) AS Query23 WHERE stamp<NOW();

/*DISCHARGED*/

SELECT mID, cID, tID, itemID, uPrice, addr, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, addr, GREATEST(Query73.stamp,Query79.stamp13) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query73 NATURAL JOIN (SELECT mID, cID, tID, addr ,stamp AS stamp13 FROM (SELECT mID, cID, tID, addr, qty, GREATEST(Query74.stamp,Query81.stamp14) AS stamp FROM (SELECT mID, cID, tID, addr, stamp FROM Shipment) AS Query74 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp14 FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query75) AS Query81 WHERE '1000-01-01 00:00:00'<=Query74.stamp AND Query74.stamp<Query81.stamp14+Interval 5 day) AS Query76) AS Query79) AS Query77 WHERE stamp<NOW();

/*VIOLATED*/

SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query89.stamp,Query103.stamp16) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query83.stamp,Query105.stamp17) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query83 NATURAL JOIN (SELECT mID, cID, tID, qty, addr, pPrice ,stamp AS stamp17 FROM (SELECT mID, cID, tID, qty, addr, pPrice, GREATEST(Query84.stamp,Query107.stamp18) AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query84 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp18 FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query85.stamp,Query109.stamp19) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query85 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp19 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query86) AS Query109 WHERE '1000-01-01 00:00:00'<=Query85.stamp AND Query85.stamp<Query109.stamp19+Interval 4 day) AS Query87) AS Query107) AS Query88) AS Query105) AS Query89 NATURAL JOIN (SELECT mID, cID, tID, addr ,stamp AS stamp16 FROM (SELECT mID, cID, tID, addr, stamp FROM Shipment WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'1000-01-01 00:00:00') AS Query94) AS Query103) AS Query95 UNION SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query98.stamp,Query100.stamp15) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query83.stamp,Query111.stamp20) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query83 NATURAL JOIN (SELECT mID, cID, tID, qty, addr, pPrice ,stamp AS stamp20 FROM (SELECT mID, cID, tID, qty, addr, pPrice, GREATEST(Query84.stamp,Query113.stamp21) AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query84 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp21 FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query85.stamp,Query115.stamp22) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query85 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp22 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query86) AS Query115 WHERE '1000-01-01 00:00:00'<=Query85.stamp AND Query85.stamp<Query115.stamp22+Interval 4 day) AS Query87) AS Query113) AS Query88) AS Query111) AS Query98 WHERE (mID, cID, tID, addr) NOT IN (SELECT mID, cID, tID, addr FROM (SELECT mID, cID, tID, addr, qty, GREATEST(Query90.stamp,Query117.stamp23) AS stamp FROM (SELECT mID, cID, tID, addr, stamp FROM Shipment) AS Query90 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp23 FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query91) AS Query117 WHERE '1000-01-01 00:00:00'<=Query90.stamp AND Query90.stamp<Query117.stamp23+Interval 5 day) AS Query97)) AS Query98 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp15 FROM (SELECT mID, cID, tID, qty, addr ,stamp+Interval 5 day AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) ASQuery91) AS Query99) AS Query100) AS Query92 WHERE stamp<NOW();

/*For Nested, we obtain these queries:*/

/*CREATED*/

SELECT mID, cID, tID, itemID, uPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query119 WHERE stamp<NOW();

/*DETACHED*/

SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query121.stamp,Query124.stamp24) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query121 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice ,stamp AS stamp24 FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query89.stamp,Query135.stamp26) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query83.stamp,Query137.stamp27) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query83 NATURAL JOIN (SELECT mID, cID, tID, qty, addr, pPrice ,stamp AS stamp27 FROM (SELECT mID, cID, tID, qty, addr, pPrice, GREATEST(Query84.stamp,Query139.stamp28) AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query84 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp28 FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query85.stamp,Query141.stamp29) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query85 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp29 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query86) AS Query141 WHERE '1000-01-01 00:00:00'<=Query85.stamp AND Query85.stamp<Query141.stamp29+Interval 4 day) AS Query87) AS Query139) AS Query88) AS Query137) AS Query89 NATURAL JOIN (SELECT mID, cID, tID, addr ,stamp AS stamp26 FROM (SELECT mID, cID, tID, addr, stamp FROM Shipment WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'1000-01-01 00:00:00') AS Query126) AS Query135) AS Query127 UNION SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query130.stamp,Query132.stamp25) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query83.stamp,Query143.stamp30) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query83 NATURAL JOIN (SELECT mID, cID, tID, qty, addr, pPrice ,stamp AS stamp30 FROM (SELECT mID, cID, tID, qty, addr, pPrice, GREATEST(Query84.stamp,Query145.stamp31) AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query84 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp31 FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query85.stamp,Query147.stamp32) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query85 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp32 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query86) AS Query147 WHERE '1000-01-01 00:00:00'<=Query85.stamp AND Query85.stamp<Query147.stamp32+Interval 4 day) AS Query87) AS Query145) AS Query88) AS Query143) AS Query130 WHERE (mID, cID, tID, addr) NOT IN (SELECT mID, cID, tID, addr FROM (SELECT mID, cID, tID, addr, qty, GREATEST(Query90.stamp,Query149.stamp33) AS stamp FROM (SELECT mID, cID, tID, addr, stamp FROM Shipment) AS Query90 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp33 FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query91) AS Query149 WHERE '1000-01-01 00:00:00'<=Query90.stamp AND Query90.stamp<Query149.stamp33+Interval 5 day) AS Query129)) AS Query130 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp25 FROM (SELECT mID, cID, tID, qty, addr ,stamp+Interval 5 day AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) ASQuery91) AS Query131) AS Query132) AS Query92) AS Query124) AS Query122 WHERE stamp<NOW();

/*EXPIRED*/

SELECT mID, cID, tID, itemID, uPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query151.stamp,Query161.stamp34) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query151 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice ,stamp AS stamp34 FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query89.stamp,Query172.stamp36) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query83.stamp,Query174.stamp37) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query83 NATURAL JOIN (SELECT mID, cID, tID, qty, addr, pPrice ,stamp AS stamp37 FROM (SELECT mID, cID, tID, qty, addr, pPrice, GREATEST(Query84.stamp,Query176.stamp38) AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query84 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp38 FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query85.stamp,Query178.stamp39) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query85 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp39 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query86) AS Query178 WHERE '1000-01-01 00:00:00'<=Query85.stamp AND Query85.stamp<Query178.stamp39+Interval 4 day) AS Query87) AS Query176) AS Query88) AS Query174) AS Query89 NATURAL JOIN (SELECT mID, cID, tID, addr ,stamp AS stamp36 FROM (SELECT mID, cID, tID, addr, stamp FROM Shipment WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'1000-01-01 00:00:00') AS Query163) AS Query172) AS Query164 UNION SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query167.stamp,Query169.stamp35) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query83.stamp,Query180.stamp40) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query83 NATURAL JOIN (SELECT mID, cID, tID, qty, addr, pPrice ,stamp AS stamp40 FROM (SELECT mID, cID, tID, qty, addr, pPrice, GREATEST(Query84.stamp,Query182.stamp41) AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query84 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp41 FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query85.stamp,Query184.stamp42) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query85 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp42 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query86) AS Query184 WHERE '1000-01-01 00:00:00'<=Query85.stamp AND Query85.stamp<Query184.stamp42+Interval 4 day) AS Query87) AS Query182) AS Query88) AS Query180) AS Query167 WHERE (mID, cID, tID, addr) NOT IN (SELECT mID, cID, tID, addr FROM (SELECT mID, cID, tID, addr, qty, GREATEST(Query90.stamp,Query186.stamp43) AS stamp FROM (SELECT mID, cID, tID, addr, stamp FROM Shipment) AS Query90 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp43 FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query91) AS Query186 WHERE '1000-01-01 00:00:00'<=Query90.stamp AND Query90.stamp<Query186.stamp43+Interval 5 day) AS Query166)) AS Query167 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp35 FROM (SELECT mID, cID, tID, qty, addr ,stamp+Interval 5 day AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) ASQuery91) AS Query168) AS Query169 WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'1000-01-01 00:00:00') AS Query154) AS Query161) AS Query155 UNION SELECT mID, cID, tID, itemID, uPrice, GREATEST(stamp,CAST('9999-12-31 23:59:59' AS DATETIME)) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query158 WHERE (mID, cID, tID, itemID, uPrice) NOT IN (SELECT mID, cID, tID, itemID, uPrice FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query89.stamp,Query197.stamp45) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query83.stamp,Query199.stamp46) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query83 NATURAL JOIN (SELECT mID, cID, tID, qty, addr, pPrice ,stamp AS stamp46 FROM (SELECT mID, cID, tID, qty, addr, pPrice, GREATEST(Query84.stamp,Query201.stamp47) AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query84 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp47 FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query85.stamp,Query203.stamp48) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query85 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp48 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query86) AS Query203 WHERE '1000-01-01 00:00:00'<=Query85.stamp AND Query85.stamp<Query203.stamp48+Interval 4 day) AS Query87) AS Query201) AS Query88) AS Query199) AS Query89 NATURAL JOIN (SELECT mID, cID, tID, addr ,stamp AS stamp45 FROM (SELECT mID, cID, tID, addr, stamp FROM Shipment WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'1000-01-01 00:00:00') AS Query188) AS Query197) AS Query189 UNION SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query192.stamp,Query194.stamp44) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query83.stamp,Query205.stamp49) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query83 NATURAL JOIN (SELECT mID, cID, tID, qty, addr, pPrice ,stamp AS stamp49 FROM (SELECT mID, cID, tID, qty, addr, pPrice, GREATEST(Query84.stamp,Query207.stamp50) AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query84 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp50 FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query85.stamp,Query209.stamp51) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query85 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp51 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query86) AS Query209 WHERE '1000-01-01 00:00:00'<=Query85.stamp AND Query85.stamp<Query209.stamp51+Interval 4 day) AS Query87) AS Query207) AS Query88) AS Query205) AS Query192 WHERE (mID, cID, tID, addr) NOT IN (SELECT mID, cID, tID, addr FROM (SELECT mID, cID, tID, addr, qty, GREATEST(Query90.stamp,Query211.stamp52) AS stamp FROM (SELECT mID, cID, tID, addr, stamp FROM Shipment) AS Query90 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp52 FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query91) AS Query211 WHERE '1000-01-01 00:00:00'<=Query90.stamp AND Query90.stamp<Query211.stamp52+Interval 5 day) AS Query191)) AS Query192 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp44 FROM (SELECT mID, cID, tID, qty, addr ,stamp+Interval 5 day AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) ASQuery91) AS Query193) AS Query194 WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'9999-12-31 23:59:59') AS Query157)) AS Query158) AS Query152 WHERE stamp<NOW();

/*DISCHARGED*/

SELECT mID, cID, tID, itemID, uPrice, rAmount, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, rAmount, GREATEST(Query213.stamp,Query217.stamp53) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query213 NATURAL JOIN (SELECT mID, cID, tID, rAmount ,stamp AS stamp53 FROM (SELECT mID, cID, tID, rAmount, stamp FROM Refund) AS Query214) AS Query217) AS Query215 WHERE stamp<NOW();

/*VIOLATED*/

SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, rAmount, GREATEST(Query220.stamp,Query231.stamp54) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query219.stamp,Query233.stamp55) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query219 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice ,stamp AS stamp55 FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query89.stamp,Query244.stamp57) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query83.stamp,Query246.stamp58) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query83 NATURAL JOIN (SELECT mID, cID, tID, qty, addr, pPrice ,stamp AS stamp58 FROM (SELECT mID, cID, tID, qty, addr, pPrice, GREATEST(Query84.stamp,Query248.stamp59) AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query84 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp59 FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query85.stamp,Query250.stamp60) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query85 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp60 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query86) AS Query250 WHERE '1000-01-01 00:00:00'<=Query85.stamp AND Query85.stamp<Query250.stamp60+Interval 4 day) AS Query87) AS Query248) AS Query88) AS Query246) AS Query89 NATURAL JOIN (SELECT mID, cID, tID, addr ,stamp AS stamp57 FROM (SELECT mID, cID, tID, addr, stamp FROM Shipment WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'1000-01-01 00:00:00') AS Query235) AS Query244) AS Query236 UNION SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query239.stamp,Query241.stamp56) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query83.stamp,Query252.stamp61) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query83 NATURAL JOIN (SELECT mID, cID, tID, qty, addr, pPrice ,stamp AS stamp61 FROM (SELECT mID, cID, tID, qty, addr, pPrice, GREATEST(Query84.stamp,Query254.stamp62) AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query84 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp62 FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query85.stamp,Query256.stamp63) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query85 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp63 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query86) AS Query256 WHERE '1000-01-01 00:00:00'<=Query85.stamp AND Query85.stamp<Query256.stamp63+Interval 4 day) AS Query87) AS Query254) AS Query88) AS Query252) AS Query239 WHERE (mID, cID, tID, addr) NOT IN (SELECT mID, cID, tID, addr FROM (SELECT mID, cID, tID, addr, qty, GREATEST(Query90.stamp,Query258.stamp64) AS stamp FROM (SELECT mID, cID, tID, addr, stamp FROM Shipment) AS Query90 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp64 FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query91) AS Query258 WHERE '1000-01-01 00:00:00'<=Query90.stamp AND Query90.stamp<Query258.stamp64+Interval 5 day) AS Query238)) AS Query239 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp56 FROM (SELECT mID, cID, tID, qty, addr ,stamp+Interval 5 day AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) ASQuery91) AS Query240) AS Query241) AS Query92) AS Query233) AS Query220 NATURAL JOIN (SELECT mID, cID, tID, rAmount ,stamp AS stamp54 FROM (SELECT mID, cID, tID, rAmount, stamp FROM Refund WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'1000-01-01 00:00:00') AS Query224) AS Query231) AS Query225 UNION SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(stamp,CAST('9999-12-31 23:59:59' AS DATETIME)) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query219.stamp,Query260.stamp65) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query219 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice ,stamp AS stamp65 FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query89.stamp,Query271.stamp67) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query83.stamp,Query273.stamp68) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query83 NATURAL JOIN (SELECT mID, cID, tID, qty, addr, pPrice ,stamp AS stamp68 FROM (SELECT mID, cID, tID, qty, addr, pPrice, GREATEST(Query84.stamp,Query275.stamp69) AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query84 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp69 FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query85.stamp,Query277.stamp70) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query85 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp70 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query86) AS Query277 WHERE '1000-01-01 00:00:00'<=Query85.stamp AND Query85.stamp<Query277.stamp70+Interval 4 day) AS Query87) AS Query275) AS Query88) AS Query273) AS Query89 NATURAL JOIN (SELECT mID, cID, tID, addr ,stamp AS stamp67 FROM (SELECT mID, cID, tID, addr, stamp FROM Shipment WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'1000-01-01 00:00:00') AS Query262) AS Query271) AS Query263 UNION SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query266.stamp,Query268.stamp66) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, stamp FROM (SELECT mID, cID, tID, itemID, uPrice, qty, addr, pPrice, GREATEST(Query83.stamp,Query279.stamp71) AS stamp FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query83 NATURAL JOIN (SELECT mID, cID, tID, qty, addr, pPrice ,stamp AS stamp71 FROM (SELECT mID, cID, tID, qty, addr, pPrice, GREATEST(Query84.stamp,Query281.stamp72) AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query84 NATURAL JOIN (SELECT mID, cID, tID, pPrice ,stamp AS stamp72 FROM (SELECT mID, cID, tID, pPrice, itemID, uPrice, GREATEST(Query85.stamp,Query283.stamp73) AS stamp FROM (SELECT mID, cID, tID, pPrice, stamp FROM Payment) AS Query85 NATURAL JOIN (SELECT mID, cID, tID, itemID, uPrice ,stamp AS stamp73 FROM (SELECT mID, cID, tID, itemID, uPrice, stamp FROM Quote) AS Query86) AS Query283 WHERE '1000-01-01 00:00:00'<=Query85.stamp AND Query85.stamp<Query283.stamp73+Interval 4 day) AS Query87) AS Query281) AS Query88) AS Query279) AS Query266 WHERE (mID, cID, tID, addr) NOT IN (SELECT mID, cID, tID, addr FROM (SELECT mID, cID, tID, addr, qty, GREATEST(Query90.stamp,Query285.stamp74) AS stamp FROM (SELECT mID, cID, tID, addr, stamp FROM Shipment) AS Query90 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp74 FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) AS Query91) AS Query285 WHERE '1000-01-01 00:00:00'<=Query90.stamp AND Query90.stamp<Query285.stamp74+Interval 5 day) AS Query265)) AS Query266 NATURAL JOIN (SELECT mID, cID, tID, qty, addr ,stamp AS stamp66 FROM (SELECT mID, cID, tID, qty, addr ,stamp+Interval 5 day AS stamp FROM (SELECT mID, cID, tID, qty, addr, stamp FROM POrder) ASQuery91) AS Query267) AS Query268) AS Query92) AS Query260) AS Query228 WHERE (mID, cID, tID) NOT IN (SELECT mID, cID, tID FROM (SELECT mID, cID, tID, rAmount, stamp FROM Refund WHERE '1000-01-01 00:00:00'<=stamp AND stamp<'9999-12-31 23:59:59') AS Query227)) AS Query228) AS Query222 WHERE stamp<NOW();

