SQL
Sailors(sid: integer, sname: string, rating: integer, age: real) Boats(bid: integer, bname: string, color: string) Reserves(sid: integer, bid: integer, day: dates)
Tum denizcilerin isimlerini ve yaslarini bulunuz SELECT sname, age FROM Sailors
18 yasindan kucuk denizcilerin tum bilgilerini listeleyin SELECT * FROM Sailors WHERE age < 18
103 numarali botu reserve eden denizcilerin isimlerini bulunuz SELECT S.sname FROM sailors S, Reserves R WHERE S.sid = R.sid AND R.bid = 103
Kirmizi bot reserve eden denizcilerin sid’lerini bulunuz SELECT R.sid FROM Reserves R, Boats B WHERE R.bid = B.bid AND B.color = ‘red’
Kirmizi bot reserve eden denizcilerin isimlerini bulunuz SELECT S.sname FROM Sailors S, Reserves R, Boats B WHERE S.sid = R.sid AND R.bid = B.bid and B.color = ‘kirmizi’
Bob isimli denizci tarafindan reserve edilen botlarin renklerini bulunuz SELECT B.color FROM Boats B, Reserves R, Sailors S WHERE B.bid = R.bid AND R.sid = S.sid AND S.sname = ‘Bob’
Ayni gun icinde iki farkli bot reserve eden denizcilerin isimlerini bulunuz SELECT S.sname FROM Sailors S, Reserves R1, Reserves R2 WHERE S.sid = R1.sid AND R1.sid = R2.sid AND R1.day = R2.day AND R1.bid <> R2.bid
Kirmizi veya yesil bir bot reserve eden denizcilerin isimlerini bulunuz SELECT S.sname FROM Sailors S, Reserves R, Boats B WHERE S.sid = R.sid AND R.bid = B.bid AND (B.color = ‘kirmizi’ OR B.color = ‘yesil’)
Hem kirmizi hem de yesil bot reserve eden denizcilerin isimlerini bulunuz SELECT S.sname FROM Sailors S, Reserves R1, Reserves R2, Boats B1, Boats B2 WHERE S.sid = R1.sid AND S.sid = R2.sid AND R1.bid = B1.bid AND R2.bid = B2.bid AND B1.color = ‘kirmizi’ AND B2.color = ‘yesil’
UNION, INTERECT, EXCEPT, IN op ANY, op ALL EXIST KUME ISLEMLERI
UNION – Kume Bilesimi Kirmizi ya da yesil bot reserve etmis denizcilerin isimlerini bulunuz SELECT S.sname FROM Reserves R, Boats B, Sailors S WHERE R.bid= B.bid AND B.color = ‘kirmizi’ and R.sid = S.sid UNION WHERE R.bid= B.bid AND B.color = ‘yesil’ and R.sid = S.sid
INTERSECT– Kume Kesisimi Kirmizi ve yesil bot reserve etmis denizcilerin isimlerini bulunuz SELECT S.sname FROM Reserves R, Boats B, Sailors S WHERE R.bid= B.bid AND B.color = ‘kirmizi’ and R.sid = S.sid INTERSECT WHERE R.bid= B.bid AND B.color = ‘yesil’ and R.sid = S.sid
EXCEPT: Kume farki Kirmizi bot reserve edip yesil bot reserve etmemis olan denizcilerin isimlerini bulunuz SELECT S.sname FROM Sailors S, Boats B, Reserves R WHERE S.sid = R.sid AND R.bid = B.bid AND B.color = ‘kirmizi’ EXCEPT WHERE S.sid = R.sid AND R.bid = B.bid AND B.color = ‘yesil’
IN: Kumenin elemani 103 numarali botu reserve eden denizcilerin isimlerini bulunuz SELECT S.sname FROM Sailors S WHERE S.sid IN (SELECT R.sid FROM Reserves R WHERE R.bid = 103) IC iCE girmis dongu
Hic kirmizi bot reserve etmemis denizcilerin isimlerini bulunuz SELECT S.sname FROM Sailors S WHERE S.sid NOT IN (SELECT R.sid FROM Reserves R WHERE R.bid IN (SELECT B.bid FROM Boats B WHERE B.color = ‘kirmizi’))
op ANY: op herhangi birinden Derecesi Ali’nin derecesinden daha yuksek olan denizcilerin isimlerini bulunuz SELECT S.sname FROM Sailors S WHERE S.rating > ANY(SELECT S2.rating FROM Sailors S2 WHERE S2.sname= ‘Ali’)
Derecesi en yuksek olan denizcinin ismini bulunuz SELECT S.sname FROM Sailors S WHERE S.rating >= ALL (SELECT S2. rating FROM Sailors S2)